-1

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?

Brad Werth
  • 17,411
  • 10
  • 63
  • 88
Syamantak Basu
  • 905
  • 4
  • 10
  • 20

3 Answers3

0

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.

Eldhose M Babu
  • 14,382
  • 8
  • 39
  • 44
0

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()

Søren Lorentzen
  • 868
  • 1
  • 11
  • 26
  • thanks but can u plz provide some code to save the last instance state?actually i have a grid view in a fragment.images are downloaded into the gridview through sm links.at this point if i autolock the screen...am getting a NullPointer Exception at InitGridView() method. – Syamantak Basu Aug 28 '12 at 05:31
  • 1
    Finally got a code that holds the last state of the fragment @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setRetainInstance(true); } – Syamantak Basu Aug 29 '12 at 06:03
0

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); }

Syamantak Basu
  • 905
  • 4
  • 10
  • 20