When I press the Home button, the app should be paused, save all state and work fine. Instead I get this error:
java.lang.RuntimeException: Unable to pause activity {be.test.tester/be.test.tester.DataScreen}: java.lang.IllegalStateException: Derived class did not call super.onSaveInstanceState() at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3641) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3598) at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3574) at android.app.ActivityThread.access$2500(ActivityThread.java:136) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2186) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:5068) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Derived class did not call super.onSaveInstanceState() at android.view.View.dispatchSaveInstanceState(View.java:6087) at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1207) at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1207) at android.view.View.saveHierarchyState(View.java:6068) at com.android.internal.policy.impl.PhoneWindow.saveHierarchyState(PhoneWindow.java:1475) at android.app.Activity.onSaveInstanceState(Activity.java:1106) at android.app.Activity.performSaveInstanceState(Activity.java:1056) at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1289) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3623) ... 12 more
My activity reacts on touch:
public class DataScreen extends Activity implements OnGestureListener{
I'm getting some extra's from the intent:
totUsage = Integer.parseInt(getIntent().getStringExtra("extraTotUsage"));
limit = Integer.parseInt(getIntent().getStringExtra("extraLimit"));
Bundle bundle = getIntent().getExtras();
mylist = (ArrayList<HashMap<String, String>>) bundle.get("extraMyList");
A custom view is showing data (canvas). When you scroll on screen, data changes in custom view (set, get method) and redraws itself.
I don't really manage the onSaveInstanceState here, don't really know if I have to.
My app is onTop of the stack, because of:
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
I don't understand the error.
You should override onSaveInstanceState and call its super method like shown below. At least it helped me with the same problem.
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
// your stuff or nothing
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// your stuff or nothing
}