Application is launching twice if opening from a h

2019-06-27 09:53发布

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条回答
Deceive 欺骗
2楼-- · 2019-06-27 10:13

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"

查看更多
登录 后发表回答