[英]How do I make a Home Screen Application not be recreated when pressing the home button
Pardon my dodgy explanation in the title. 请原谅我标题中的狡猾解释。 What happens is: I'm trying to make a home screen application. 发生的事情是:我正在尝试制作主屏幕应用程序。 So far so good, I made the app launcher that launches an application when executed. 到目前为止,我已经做好了使应用程序启动器在执行时启动应用程序的工作。 But, if for example I press the home screen to be taken back to my application, instead of continuing the activity from onResume() it relaunches the application from onCreate(); 但是,例如,如果我按主屏幕返回到我的应用程序,而不是继续从onResume()执行活动,它将从onCreate()重新启动应用程序;
this is the code i use to launch e new activity: 这是我用来启动新活动的代码:
PackageManager pm=getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(applications.get(c).pname);
startActivity(intent);
Any idea how I can make it so that when I press the Home button it doesn't relaunch the whole app? 知道如何才能做到这一点,以便当我按下“主页”按钮时不会重新启动整个应用程序吗?
在活动上设置android:launchMode="singleInstance"
属性。
@femi @femi
thanks your answer was really great, it was exactly what i was looking for :) 谢谢你的回答真的很棒,这正是我在寻找的东西:)
<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.