0

I developed an android application with two screens. The application is working with android devices good. But i installed application in amazon kindle fire tablet launched the application started good. I navigated from 1st screen to 2nd screen and pressed home button. And again i launched application from applications menu. application is showing 1st screen instead of 2nd screen. Common behavior of android is should show the second screen.

What i know is while press on home button the application will go for onPause() state and launch application form launcher icon it will go fore onResume and show the screen where it has previously. But application every time calling onCreate when launching from launcher icon. This happened in Amazon kinlde fire tablet only.

I am starting the 2nd activity from 1st activity using startActivity(intent); method May i need to use any flag for kindle fire tablet.

Please suggest me as ASAP. Thanks in advance.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Raghu Mudem
  • 6,793
  • 13
  • 48
  • 69

1 Answers1

0

Android doesn't guarantee that once you press back from an activity, it will remain in the onPause state. It depends on how aggressive the memory killer is, or how low the device memory is. What this means is, don't count on your application being in onPause state ever.

What you could do is, save the activity state in a shared preference, and let the Application object launch the corresponding activity, restoring UI state if required.

Aswin Kumar
  • 5,158
  • 5
  • 34
  • 39
  • Could you please gave me any code idea for this concept. Thank you – Raghu Mudem Aug 16 '12 at 11:47
  • Do something like this: say you are in `actvityA`. In `onPause()`, write a shared preference, say `currentActivity`, with its value set to `activityA.class.getSimpleName()`. When the app is launched again, the `Application` object will be created (if you are not familiar with the concept of `Application` objects, you can see [here](http://developer.android.com/reference/android/app/Application.html), [here](http://www.helloandroid.com/category/topics-covered/application-object) or simply google). Here, you get the preference, check whether it is set to activityA or activityB, and start it off. – Aswin Kumar Aug 16 '12 at 13:37