I think it is due to low memory if I set the app background.
The log is like below:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.qingdaonews.bus/com.qingdaonews.activity.RealTime}:
java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.view.View$BaseSavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/myviewpager. Make sure other views do not use the same id.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.access$600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
It looks like due to the same id of a view.In fact ,the id 'myviewpager' only appear once in the xml file and the problem only occur when the app is reopen from background.
And my MainActivity has one fragment which can be replaced in it.I use getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commit();
when I start the activity.
Without super method of 'savedInstanceState',I did not use something else.