5

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>
user2678020
  • 291
  • 1
  • 2
  • 6

1 Answers1

0

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"

Nitin Misra
  • 4,472
  • 3
  • 34
  • 52
  • Yes this intent filter is there,still it is not working – user2678020 Sep 09 '13 at 09:15
  • Add this it will surely remove your problem (I guess so) `android:launchMode="singleTask"` in place of `android:launchMode="singleInstance"` – Nitin Misra Sep 09 '13 at 09:25
  • I tried android:launchMode="singleInstance" but unfortunately it is not resolving. When i am pressing the Home key and coming back again then it is fine but if I am trying to launch my application from some other hyperlink(Calendar Hyperlink) then it is showing the two instances – user2678020 Sep 09 '13 at 09:50
  • I asked you to use `singleTask` instead of `singleInstance` – Nitin Misra Sep 09 '13 at 09:55
  • Yeh Sorry I mean to say that I checked with android:launchMode="singleTask" also but it is not working – user2678020 Sep 09 '13 at 10:42