Android makes a switch to rereate () activity

I want to add a switch to rereate () activity after changing the topic, is this possible?

I tried: @android: anime / fade _in @android: anime / fade _out but it didn’t work and it will also affect the transition when opening and closing activity, but I don’t want

+16
android android-activity animation transition recreate
source share
2 answers

Well, you can use this instead of recreate ()

Activity mCurrentActivity = getActivity(); ... mCurrentActivity.finish(); mCurrentActivity.overridePendingTransition(R.anim.transition_for_incoming_activity, R.anim.transition_for_outgoing_activity); mCurrentActivity.startActivity(mCurrentActivity.getIntent()); 
0
source share

To “save state” with @Arunava's answer, follow these steps:

  Activity mCurrentActivity = getActivity(); Intent intent = getActivity().getIntent(); Bundle tempBundle = new Bundle(); intent.putExtra("bundle", tempBundle); mCurrentActivity.finish(); mCurrentActivity.overridePendingTransition(R.anim.transition_for_incoming_activity, R.anim.transition_for_outgoing_activity); mCurrentActivity.startActivity(intent); 

and then do it in your creation activity

  @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getIntent().hasExtra("bundle")){ //Insert a method to display the activity or fragment that triggered the activity to restart } super.onResume(); } 
0
source share

All Articles