Deep Linkng: Open Multiple Apps with same host but different pathPrefix - android

I am using Deep Linking in my application. But, now I have a requirement of opening two seperate apps on two seperate url's but same host like
http:www.google.com/Nexus5 - This should open App1
http:www.google.com/Nexus6 - This should open App2
The above url opens both the apps, but my requirement is that If I provide complete url like http:www.google.com/Nexus5 then it should only show option to of App1.
So, its like if I pass on url
http:www.google.com/Nexus5 then only Nexus5 app should open and show option to browse the app. There should be no option to open Nexus6 app.
Same way for http:www.google.com/Nexus6 if I open Nexus6 url the it should not show option of Nexus5 App.
Below is my AndroidManifest file for that Activity,
<activity
android:name=".DeepLinkDemo"
android:label="#string/app_name">
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.google.com"
android:pathPrefix="/Nexus5"
android:scheme="http" />
</intent-filter>
</activity>
Now, this will run fine but if there is any other app with same host that means www.google.com I want to restrict that app from showing in the Browsable list(that other app will also be controlled by me)
So, is there anyway for achieving my above requirement?
Let, me know if anyone has any query!

You can use android:pathPattern to uniquely identify different application

Related

Are there any (poorly documented) changes to IntentFilter's and exported components in Android 12?

We use declarations like the following one (Manifest) to link to certain parts of the app:
<activity
android:name=".some.package.SomeActivity"
android:launchMode="singleInstance"
android:exported="true">
<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="https" />
<data android:host="*.some-domain.com" />
<data android:path="/native/foo" />
</intent-filter>
</activity>
On devices running Android 12, this suddenly stopped working, e.g. scanning a QR code containing a certain URL automatically opens it in the default browser. Prior to Android 12, the system offers to open those URLs in our app when tapping on links like https://some.domain.com/native/foo/bar/. I went through the changelog and was unable to find anything that could explain this behavior (considering we already set exported="true").
What am I missing and how can I tell the system to offer our app to handle those specific URLs?
UPDATE
After test some case, I found you should change your scheme from https to non https string, such as your_app_string. If you still want to use https as your scheme, you should check the doordash's tech blog.
Your should make the android system can verify your scheme.In simple words,start with android 12(api 31), you need Declare the association between your website and your intent filters by hosting a Digital Asset Links JSON file at the following location:
https://some.domain.com/.well-known/assetlinks.json
official doc reference here

Android - Setting the app's default "Open supported links" option

How can I control the default Open supported links to either Ask every time or Open in this app for my Android app? Does it happen in the manifest?
I have two apps that try to accept the same universal link scheme, and the ideal behavior is to have the user decide which app to open when they click on the link. However, it seems that the first app correctly has the Open supported links in settings set to Ask every time, while the other app has the Open supported links as Open in this app. Thus, when both apps are installed, only the second one will be opened straight away, whereas the first one won't even be prompted.
The portion that accepts universal links in both of the AndroidManifest.xml files are almost identical.
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="foo.bar.com" android:pathPrefix="/action/" android:scheme="https" />
</intent-filter>

How to add my application to the list of applications that can open images?

When an application on a device tries to share an image, opens a list of applications that can do something with that image: publish it on social networks, edit, etc. What should I add to the manifest file of my application in order to add my application to this list? And, basically, it is interesting what to add to the config.xml in the PhoneGap project.
In order to register your application capable to do certain tasks like open images from storage, you need to add the following code inside the activity tag that can do that task:
<activity android:name=".MyImageActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
Intent filters inform the system what intents an application component is willing to accept.
You can find more information on the official developer website: https://developer.android.com/training/sharing/receive
Take a look for this url May be it is help you for your solution
Open with menu

Open a specific url with my app without removing other apps

I have an android app with manifest file like this:
<intent-filter>
<data android:host="myurl.com"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
which means my app can open urls match whit a given filter.
In most android devices this works fine, but in some devices like samsung A5 2016 when user clicks on links like this android doesn't show other browsers and automatically open the link with my app.
I use normal Intent to open links in my app. But I can't fix the problem.
Can anyone help me?
It seems because I added intent-filter to my manifest file it blocks other apps to run this url.
I removed intent-filter from manifest file and it worked. But I wanna my app to be able to open urls which I mentioned in manifest file.

Make a link to a url start up my app and not open embedded

I defined the following intent filter in my application in order to make it respond to url links.
<intent-filter>
<data android:scheme="http"/>
<data android:scheme="https"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
Now when I click a link in an external app (from example a link sent by sms) it opens my app in an embedded way in the current application. Meaning that if I go to background I see my app inside the sms application.
I want the link to make my application to be opened separately. This is the correct behaviour, and happens for example when choosing chrome/ android native browser as the app to open the link.
Is there a way to change that for my app as well?
You have to set the launchMode of your activity to singleTask or singleInstance. This will force the system to open a new task for your app instead of opening it in the same task as the sms-app or whatever.
It should look somehow like this:
<activity android:name="yourActivity"
android:launchMode="singleTask">
&lt/activity>
For more information, see the documentation: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

Categories

Resources