Don't want to refresh tabsactivity when call f

2019-08-11 13:23发布

问题:

I am trying to stop refreshing my tabs activity, in the below pictures, you can see when I start new activity from tab fragment and then close it by pressing back button and returning to the tabs activity, all tabs will be restarted. I need to somehow resume tabs activity,

In the codes below, I call new activity:

Intent i = new Intent(context, New_Activity.class);
startActivity(i); 

and close it in this way:

finish();

回答1:

Instead of finish just use flag for it like this way

Intent intent = new Intent(current_context, destination_activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);