Android app calls onCreate when it should call onrestart

After opening the Android application and pressing the Android home button, onPause and onStop are called as expected. However, when I try to load the application again from the recent Activities list onCreate is called instead of the expected onRestart. I do not see a call to onDestroy. This is causing my application to completely restart instead of the behaviour I want which is to load the app in the state it was left off in when I first pressed the home button.

How do I get it to load the state it was in when I first pressed the home button?

Are you sure that OS doesn’t close the app because other apps need more memory?

There are no other apps running and I can see the App in the recent activities list. If the OS was destroying the activity, onDestroy should be called and I shouldn’t see it in the recent activities list.

Nevermind, I just read this:

So, it looks like it is probably destroying it because my app does take up quite a bit of memory. I’ve also read that it will call onCreate on the last activity that was in use, but Unity only ever uses 1 activity, correct?

Ok, so I just tried doing this with a new Unity project that should take up very little memory and it still has the same behaviour where it has to reload the entire app and I can see the Unity splash screen. So, it doesn’t look like its because the App is taking up a large amount of memory

I have an Android library plugin. The manifest file looks like this:




I have found another thread that has the same issue: http://forum.unity3d.com/threads/127794-Android-Apps-crashing-on-resume but I’ve added the configChanges to the manifest file and I still have the same issue.

This is the output of the logcat when the app crashes:

I/ActivityManager( 428): START u0 {act=com.android.systemui.recent.action.TOGGLE_RECENTS flg=0x10800000 cmp=com.android.systemui/.recent.RecentsActivity} from pid 544
D/dalvikvm( 428): GC_FOR_ALLOC freed 662K, 17% free 17623K/21220K, paused 68ms, total 68ms
D/dalvikvm( 428): GC_FOR_ALLOC freed 504K, 18% free 17610K/21220K, paused 63ms, total 63ms
I/ActivityManager( 428): Displayed com.android.systemui/.recent.RecentsActivity: +103ms
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeVideoFrameCallback:VILII
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSoftInputClosed:V
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetTouchDeltaY:VF
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetInputString:VL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetInputCanceled:VZ
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetExtras:VL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetDefaultDisplay:VI
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeResume:V
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeResize:VIIII
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRequestedAA:I
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRequested32bitDisplayBuffer:Z
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRender:Z
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRecreateGfxState:VL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativePause:Z
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeKeysPressed:VL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeInjectEvent:ZL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeInitWWW:VL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeFocusChanged:VZ
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeFile:VL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeDone:V
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeActivityIndicatorStyle:I
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.initJni:VL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.UnitySendMessage:VLLL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetLocationStatus:VI
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetLocation:VFFFFDF
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeForwardEventsToDalvik:VZ
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeDeviceOrientation:VI
D/dalvikvm(22450): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodUnblockStreaming:I
D/dalvikvm(22450): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcess:IL
D/dalvikvm(22450): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodInitJni:I
D/dalvikvm(22450): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodGetInfo:II
D/dalvikvm(22450): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodBlockStreaming:I
D/dalvikvm(22450): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcessMicData:ILI
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/ReflectionHelper;.nativeProxyInvoke:LILL
D/dalvikvm(22450): Unregistering JNI method Lcom/unity3d/player/ReflectionHelper;.nativeProxyFinalize:VI
I/Process (22450): Sending signal. PID: 22450 SIG: 9
I/WindowState( 428): WIN DEATH: Window{426998e8 u0 com.ix.app/com.ix.nimbus.NimbusActivity}
I/ActivityManager( 428): Process com.ix.app (pid 22450) has died.