Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deep linking and multiple app instances

I have implemented deep linking in my app. I added this intent filter in my manifest file, and the deep linking is working.

<intent-filter>     <action android:name="android.intent.action.VIEW" />      <category android:name="android.intent.category.DEFAULT" />      <category android:name="android.intent.category.BROWSABLE" />      <category android:name="android.intent.category.VIEW" />      <data         android:host="www.mywebsite.com"         android:pathPrefix="/something"         android:scheme="http" /> </intent-filter> 

The problem is that through deep linking, my app is launching on top of current app. If I am in Gmail and I click a link, then my app is launching on top of Gmail. I want to launch my app differently.

If my app is already running in background and I click on a link in Gmail which redirects to my app, I will have two instances of my app running at the same time; one in the background, and another on top of Gmail. I want to run only one instance of my app at a time, so it's not also on top of the current app (Gmail). How can I do that?

like image 847
HariRam Avatar asked Sep 17 '14 07:09

HariRam


People also ask

Can you deep link to another app?

Passing search data via deep linkingDevelopers will need to submit their app and deep linking apps on both iOS and Android to be indexed by Google. Alternatively, developers can use Google's short links to deep link mobile app users if the app is installed and direct others to the webpage.

What is the difference between deep links and app links?

When a user click an URL, it might open a dialog which asks the user to select one of multiple apps handling the given URL. On the other hand, An Android App Link is a deep link based on your website URL that has been verified to belong to your website. When user clicks that URL, it opens your app.

What is the purpose of deep linking?

What is deep linking? Deep links are a type of link that send users directly to an app instead of a website or a store. They are used to send users straight to specific in-app locations, saving users the time and energy locating a particular page themselves – significantly improving the user experience.


1 Answers

You need to do following things for your Activity in your Manifest.

android:launchMode="singleTask" 

This tells the system to always launch the existing instance of the Activity if it is already created.

And you can handle the Intent then by overriding the method

onNewIntent  

See http://developer.android.com/guide/topics/manifest/activity-element.html for more information.

like image 74
Micky Avatar answered Sep 23 '22 07:09

Micky