I have an application that i have to run in kindle fire.
The application is running fine,but after kindle autolocks,application starts from beginning and not from where the application was before the autolock.
why does this happen?
I have an application that i have to run in kindle fire.
The application is running fine,but after kindle autolocks,application starts from beginning and not from where the application was before the autolock.
why does this happen?
Try :
android:configChanges=["mcc", "mnc", "locale",
"touchscreen", "keyboard", "keyboardHidden",
"navigation", "screenLayout", "fontScale", "uiMode",
"orientation", "screenSize", "smallestScreenSize"]
in the manifest and create an override function for onConfigChange in activity.
Make sure you are saving your application's state.
Activities in Android have a very special lifecycle. Whenever an app is put in the background, it calles onPause()
and when you bring it back into view, onResume()
is called.
So you'll want to save the state whenever onPause()
or onStop()
is called and load the state on onCreate()
and onResume()
For more about states, read here
Edit: Also have a look at onSaveInstanceState()
Finally got a code that holds the last state of the fragment after kindle/galaxy tab autolocks. @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setRetainInstance(true); }