unity生成AndroidApk,只能首次啓動啓動,且後續關閉後重啓再也不啓動。android
在Manifest文件中以下設置:android:priority設置較高是爲了保證在其餘launcher前啓動。spa
<intent-filter android:priority="2000"> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>
public void DisableSetupWizard() { const int COMPONENT_ENABLED_STATE_DISABLED = 2; const int DONT_KILL_APP = 1; AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"); AndroidJavaObject pm = currentActivity.Call<AndroidJavaObject>("getPackageManager"); AndroidJavaObject component = new AndroidJavaObject("android.content.ComponentName", "包名", "類名"); pm.Call("setComponentEnabledSetting", component, COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP); }