I have a splash screen that goes to my main activity and uses a transition animation.
I want to know how to stop the animation if I 'swipe' the application from my app list. Currently if I do this you will still see the animation on top of my phone's home screen.
Splash screen:
intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
finish();
I have tried some of these, but with no success:
overridePendingTransition(0, 0);
or
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
or
finish();
etc.
Any ideas?
Related
I'm trying to open an already activity with animation open.
It will run it only first time which activity starts and then it will not work again
Here is the code :
var intent = new Intent(this, typeof(TableItemsMain))
.SetFlags(ActivityFlags.ReorderToFront);
StartActivity(intent);
OverridePendingTransition(Resource.Layout.trans_left_in, Resource.Layout.trans_left_out);
I want to restart my Android app, but I want it to go to a specific activity after the app restart.
I am currently using this code to re launch my app, but it starts back to the first activity. I need it to go to another specific activity.
I made a settings page in my application where users can choose their own app colors. After choosing a color, i need to restart all activities to apply the new theme that the user chose.
code I am using to restart app to first activity:
Intent startActivity = new Intent();
startActivity.setClass(ProfileSettingsActivity.this,ProfileSettingsActivity.class);
startActivity(startActivity);
finish();
easy
Intent intent = new Intent(this, ANOTHER_SPECIFIC_ACTIVITY.class);
this.startActivity(intent);
finish();
In the onCreate() of your first activity, check for whatever conditions you want, and then based on those conditions launch the intent for your specific activity before the setContentView() is called in the first activity.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(CONDITION_1) {
startActivity(new Intent(this, ActivityA.class));
} else if(CONDITION_2) {
startActivity(new Intent(this, ActivityB.class));
}
setContentView(R.layout.activity_first);
}
Have you tried clearing all activities and launch the new one with Flags?
Intent intent = new Intent(this, NEW_ACTIVITY.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Doing this, you are clearing all activities previously created and launch NEW_ACTIVITY.class with the new configuration.
I have an app that I'm writing that starts with an initial Login/Create New Account splash screen. In onCreate it checks my SharedPreferences to see if user credentials are stored. If they are the activity launches an intent to the main activity skipping the login/create process.
if (haveCredentials()) {
Intent i = new Intent(this, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
I don't want the user to be able to go back to the splash screen. As you can see I'm trying the CLEAR_TOP Intent flag as suggested by this but it doesn't seem to be working. Not sure what I'm missing.
Current State of the Activity Stack
SplashActivity->MainActivity
Desired State of the Stack
MainActivity
Have you tried finishing the current activity?
if (haveCredentials()) {
Intent i = new Intent(this, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish(); //add this!
}
Just use finish() after startActivity(), so that when back button is pressed the previous activity will not be shown.
I got two activities, one active and other paused and I want to close/finish all the two activities and start another intent. I tried this inside the active activity:
finish();
Intent intent = new Intent(getApplicationContext(), Init.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
then I tried to close the program inside Init class and it appeared me the previous paused activity. How can I solve this problem ?
Try calling not calling finish() before you launch the newest intent and use these flags
Intent intent = new Intent(getApplicationContext(), Init.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
I am calling an Activity B from Activity A, which contains a Video View using the following code :
Intent intent = new Intent(this, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivityForResult(intent, 0);
I am using Intent.FLAG_ACTIVITY_NO_ANIMATION to avoid transition animation while new activity is being called. But its not working for me and a black screen is coming while the transition. Is there any way to avoid this transition animation and black screen, so that the user will not come to know that the video view is being called in a new screen?
Try calling:
Intent intent = new Intent(this, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivityForResult(intent, 0);
overridePendingTransition(0,0); //0 for no animation
if you want to do it for all activities then do it in this way:
switching activities without animation
Just assign style with no animation to each activity in manifest.
Or through code do it in this way:
Disable activity slide-in animation when launching new activity?
Took me quite some time to figure it out...
to support overriding transition when coming back from another Activity:
use overridePendingTransition in your Activity onResume.
override fun onResume() {
super.onResume()
// disable transition when coming back from an activity
overridePendingTransition(0, 0)
}