0

I have a strange problem on my Android App.

I have an Activity A which call to another Activity B. When I finish Activity B mostly in every device which I have tried returns to the Activity A, where it was.

But in a tablet with API 17,when i go finish Activity B, it is creating again Activity A and it is loading from the begining.

I have tried to use diffrents Intent's flags (FLAG_ACTIVITY_CLEAR_TOP,...) but still not working.

I cant understand how it work fine on a superior API.

Thanks for your help.

Nits_
  • 17
  • 8
  • Please provide some code – Jonas Feb 23 '16 at 12:12
  • Intent i = new Intent(getApplicationContext(), X.class); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.putExtra("Parameter", x); startActivity(i); – Nits_ Feb 23 '16 at 12:14
  • In your question.. Edit your question and show what you did with your code. Then explain what you expect and what is not working – Jonas Feb 23 '16 at 12:15

1 Answers1

0

Activity that goes to background should save and restore state. Use savedInstanceState onCreate and save state (refer) to revert back to same state. May be the device u are using has foreground 1 activity option enabled / has limited memory resources which is causing it to be killed in background.

Community
  • 1
  • 1
Dileep
  • 775
  • 5
  • 20
  • You were right Dileep, the issue was that in the Options of Debug in the device the option Don't keep activities was checked. So that was the reason why my app was loading the first Activity. My question is now, should i control this option by code??? – Nits_ Feb 23 '16 at 12:38
  • you should save state to bundle by overriding save state and restore state on recreated activity. Even if option is disabled because of resource constraints android can decide to kill the activity. Please refer http://developer.android.com/training/basics/activity-lifecycle/recreating.html – Dileep Feb 23 '16 at 16:38