- Home /
[SOLVED] Android app keeps restarting after resume
I have a unity android app which catches the event when it lost its focus to show a pause menu. However when I'm resuming the app after I press the home button, the app restarts. Tracing the logs in eclipse, onDestroy is called after resuming. I've read in my google searches that it's probably caused by the configChange tag in the manifest file, but I already included it in my project (See the code below).
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.ChronicleGames.DragonSnack" android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
<!-- Unity Activities -->
<activity android:label="@string/app_name" android:name="com.unity3d.player.UnityPlayerProxyActivity" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/app_name" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
</activity>
<activity android:label="@string/app_name" android:name="com.unity3d.player.UnityPlayerNativeActivity" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
<activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="@string/app_name" android:name="com.unity3d.player.VideoPlayer" android:screenOrientation="portrait">
</activity>
<activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:name="com.google.example.games.pluginsupport.SignInHelperActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:name="com.google.example.games.pluginsupport.SelectOpponentsHelperActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:name="com.google.example.games.pluginsupport.InvitationInboxHelperActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<!-- META-DATA -->
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 410239958398" />
<meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ 410239958398" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>
<!-- PERMISSIONS -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:glEsVersion="0x00020000" />
<supports-gl-texture android:name="GL_AMD_compressed_ATC_texture" />
<supports-gl-texture android:name="GL_ATI_texture_compression_atitc" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.sensor.accelerometer" />
<uses-feature android:name="android.hardware.touchscreen" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>
Anything I missed in my manifest file or is it probably caused by another problem? As an additional info, the app is running on the background after I press the home button as I traced it in eclipse. The restart happens upon resuming the app. I hope someone can help me on this issue. Thank you very much.
Figured it out. The intent-filter block should have been inside UnityPlayerNativeActivity and NOT UnityPlayerProxyActivity
THAN$$anonymous$$ YOU
I've just spent the whole evening trying to fix this after integrating Admob. This worked - you are amazing.
I don't know how I missed this question. Perfect. Why the admob plugin changes the main launcher i wonder?
It works, I tried unsuccessfully to call my app from a notification for hours, until I moved this intent-filter block from the UnityPlayerActivity into the UnityPlayerNativeActivity ...
THAN$$anonymous$$S!!!
Answer by ironfiftynine · Feb 20, 2018 at 01:47 PM
Figured it out. The intent-filter block should have been inside UnityPlayerNativeActivity and NOT UnityPlayerProxyActivity