我正在开发一个可以从多个地方启动的应用程序,例如日历中的超链接。 我在下面的场景中遇到了这个问题: 如果应用程序已在后台启动并运行,并且用户单击本机日历中的事件/超链接以启动应用程序。我的应用程序是作为新实例启动两次。在正在运行的应用列表中,我可以看到我的应用程序的两个实例。 我已经为我的Main活动尝试了android:launchMode =“singleInstance”和“singleInstance”属性。但仍然无法正常工作。有谁能建议我解决方案?
My Manifest如下所示:
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.org.ManishApp"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleInstance">
<intent-filter>`enter code here`
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
答案 0 :(得分:0)
您是否在清单中添加了此意图过滤器
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data
android:host="yify-torrents.com"
android:pathPrefix="/" />
</intent-filter>
pathprefix是域“example.com”之后的子目录