我有一個應用程序保持隱藏的啓動器。現在我想從撥號程序打開應用程序。所以我有一個BroadcastReceiver來處理事情。Android應用程序在意圖啓動時致命
1)首先,我展示這個應用程式,
ComponentName componentName = new ComponentName(context,
SplashActivity.class);
context.getPackageManager().setComponentEnabledSetting(
componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
2)然後啓動一個Intent,
Intent launcher = new Intent(context, SplashActivity.class);
launcher.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(launcher);
3)然後我又隱藏應用程序,
ComponentName componentName2 = new ComponentName(context,
SplashActivity.class);
context.getPackageManager().setComponentEnabledSetting(
componentName2,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
問題
意圖啓動成功,但應用程序在幾秒鐘後死亡。但是,如果我啓動除SplashActivity以外的任何其他活動,則不會發生此問題。問題是什麼?如何解決?
如果你得到錯誤,然後發佈你的logcat,所以我們可以弄明白。 – Apurva
@Apurva沒有錯誤。只是應用程序自動死亡。 –