我的Android应用程序的一个活动,由prevent多个实例 [英] Prevent multiple instances of my Android application composed of a single activity
问题描述
我是从一个单一的活动
组成的Android应用程序。
我怎样才能确保我的应用程序只有一个实例(== 活动
)将存在于一个给定的时间?
我有一个情况,就是我成功通过点击应用程序图标多次(这不会重现所有的时间),打开我的应用程序的多个实例。
I have an Android application which is composed from a single Activity
.
How can I assure that only one instance of my application (== Activity
) will exist in a given time?
I got to a situation in which I succeeded to open multiple instances of my app by clicking on the app icon multiple times (this doesn't reproduce all the time).
推荐答案
改变你的表现是这样的:
change your manifest like this:
<activity
android:name="com.yourpackage.YourActivity"
android:label="@string/app_name"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
包括安卓launchMode =singleTask
,这将是不可能让你的活动在同一时间推出的多个实例。 查看活动文档为多。
include the android:launchMode="singleTask"
and it will not be possible to have multiple instances of your Activity launched at the same time. See the activity docs for more.
这篇关于我的Android应用程序的一个活动,由prevent多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!