[英]How do I make a Home Screen Application not be recreated when pressing the home button
請原諒我標題中的狡猾解釋。 發生的事情是:我正在嘗試制作主屏幕應用程序。 到目前為止,我已經做好了使應用程序啟動器在執行時啟動應用程序的工作。 但是,例如,如果我按主屏幕返回到我的應用程序,而不是繼續從onResume()執行活動,它將從onCreate()重新啟動應用程序;
這是我用來啟動新活動的代碼:
PackageManager pm=getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(applications.get(c).pname);
startActivity(intent);
知道如何才能做到這一點,以便當我按下“主頁”按鈕時不會重新啟動整個應用程序嗎?
在活動上設置android:launchMode="singleInstance"
屬性。
@femi
謝謝你的回答真的很棒,這正是我在尋找的東西:)
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:allowTaskReparenting="true"
android:launchMode="singleInstance">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.