Application is launching twice if opening from a hyperlink

我的未来我决定 提交于 2019-12-23 13:13:03

问题


I am developing one application which can be launched from multiple places like e.g. hyperlink in Calendar. I am facing the problem in the below scenario: If application is already launched and running in the background and User clicks the event/hyperlink in Native calendar to start the appliction. My application is launching twice as a new instance. In the running app list I can see the two instances of my application. I have tried both android:launchMode="singleInstance" and "singleInstance" attribute for my Main activity.but still not working. Can anyone suggest me the solution?

My Manifest looks like below:

<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>

回答1:


Have you added this intent filter in your manifest

<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 is the sub-directory after domain "example.com"



来源:https://stackoverflow.com/questions/18693950/application-is-launching-twice-if-opening-from-a-hyperlink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!