Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resuming Application on Android with Unity

Tags:

c#

unity3d

resume

I'm trying to implement Pausing in Unity by using OnApplicationPause function.

It seems to work fine when I exit my game (on Android) by pressing home button and then comeback through list of active apps, but when I press the game icon on home screen, it restart the game instead of bringing me back.

Is there any way around this ?

like image 583
tvoloshyn Avatar asked Feb 18 '14 23:02

tvoloshyn


1 Answers

for me this was happening when I had an: android.os.DeadObjectException in the logs. (Meaning the application already died).

Check to see if you have something like this in your logs:

I/ActivityManager(  600): Restarting because process died: ActivityRecord{439f9588 u0 com.mycompany.myapp/com.unity3d.player.UnityPlayerProxyActivity}
W/ActivityManager(  600): Exception when starting activity com.mycompany.myapp/com.unity3d.player.UnityPlayerProxyActivity
W/ActivityManager(  600): android.os.DeadObjectException
W/ActivityManager(  600):   at android.os.BinderProxy.transact(Native Method)
W/ActivityManager(  600):   at android.app.ApplicationThreadProxy.scheduleLaunchActivity(ApplicationThreadNative.java:759)
W/ActivityManager(  600):   at com.android.server.am.ActivityStack.realStartActivityLocked(ActivityStack.java:1120)
W/ActivityManager(  600):   at com.android.server.am.ActivityStack.startSpecificActivityLocked(ActivityStack.java:1247)

...and if so look back even further in your logs to see why you app is dying. For me to keep the application from dying I had to move the intent filters:

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

from UnityPlayerProxyActivity to UnityPlayerNativeActivity

like image 89
Stanley Avatar answered Oct 12 '22 23:10

Stanley