android deeplink, force open externally - android

I am developing an android app which accepts deeplink. For example consider this one:
<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:host="returnapp" android:scheme="testscheme" />
</intent-filter>
So if we call the url testscheme://returnapp/?status=1 then app should be opened.
In Google Chrome it opens up and everything goes right but in firefox, the app gets opened as child of browser task (which has the link to my app). But I want it to be opened independently.
So is there something to add to manifest to force this attribute or I should add some keyword in my HTML href?
UPDATE
I think I should make a change in the link showing in webpage in firefox. Currently I am using this link:
<h1>test</h1>
Something like target="_system" to tell firefox to open this link externally.

The browsers itself need to support and implment the browsability. The browsers have to find other activities supporting android.intent.category.BROWSABLE when opening a web-page.
So as you say, Firefox is not supported for opening app directly, however there is a solution you can try is to add android:autoVerify="true" in any one of the web URL intent filters in your app manifest that include the android.intent.action.VIEW intent action and android.intent.category.BROWSABLE intent category, as shown in the following manifest code snippet:
<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="returnapp" android:scheme="testscheme" />
</intent-filter>
Even though I'm still not sure this gonna work because of android:autoVerify="true" is for appLink not for deepLink

Related

Android Intent Filter not working sometimes

I have some problems with intent filter of dynamic link.
I use Firebase Dynamic Link for deferred deep linking, so I add intent filter in my activity at manifest file.
I already use custom scheme and add dynamic link scheme after my custom scheme in same activity.
It works fine when I launch app first time and keep that first instance.
In that time, when I click dynamic link at samsung note app, my app and chrome browser are listed in chooser intent.
But after some hours without using my app so system restart my app when my app bring to foreground, my dynamic deep link intent filter not working.
In this time, when I click dynamic link at samsung note app(I think it works with implicit intent), my app doesn't listed in chooser intent and also can't receive intent filter of dynamic link.
But in same time, my custom scheme deep link working well.
Only dynamic deep link scheme not working.
And also something strange one is that it only happens in my product flavor's release mode app.
I have another flavor for develop so that flavor package name is my origin package name + ".develop" and it's debug mode.
I do same thing in same time, my develop app's dynamic deep link intent filter working fine but only my product app doesn't work.
Is this happen relative with release mode or flavor? Or I just did something wrong with adding intent filter? I really don't know why this happen.
+) I test it at real devices, Galaxy Note8(Android 9, Pie) and Galaxy A32(Android 11).
manifest file of activity:
<activity
android:name=".xxx.XxxActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- custom scheme -->
<data
android:host="xxx"
android:scheme="xxx" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<!-- Dynamic link -->
<data
android:host="xxx.page.link"
android:scheme="https"/>
</intent-filter>
</activity>

I have set my flutter app for deep links in Android, but when I tap on external link, it open my app as in-app popup. Why?

What I want to achieve is that if user tap on the link e.g. on Whatsapp:
HTTP://dev.mycompany.com/qr/asd89f7as98df78
This link will open my app supplied with the deep link.
But the issue is this link actually open my app inside the Whatsapp. So when I open the app switcher, it looks like there are two instances of my app opened. How can I fix this?
I suspect this has something to do with the way I configure my intent filter on Android Manifest. But I'm inexperienced with intent-filter. This is the current configuration for my intent filter(s):
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<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:scheme="http" android:host="dev.mycompany.com" />
<data android:scheme="https" />
</intent-filter>
Is there anything I can do to fix the problem? The first intent filter is the default when I create the app. The second one is from copy pasting from solutions I find on stack overflow. But I don't think this is the fully correct solution. I don't want the app to can be opened as popup.

Duplicate App Listing in Intent Chooser

I seem to be doing something wrong with deep linking in my app. I have two activities: a post viewer which views posts on a site, and a profile viewer which views a users profile. Below is my code that I've set up following Google's guide to deep linking.
Profile Activity Manifest Declaration
<activity
android:name=".ui.activity.ProfileActivity"
android:parentActivityName=".ui.activity.MainActivity">
<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:host="gab.ai"
android:pathPattern="/..*"
android:scheme="https" />
</intent-filter>
</activity>
Post Viewer Activity Manifest Declaration
<activity
android:name=".ui.activity.PostViewerActivity"
android:parentActivityName=".ui.activity.MainActivity">
<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:host="gab.ai"
android:pathPattern="/..*/posts/..*"
android:scheme="https" />
</intent-filter>
</activity>
I've left out the intent handling code because it is redundant. The deep links work properly, except for a weird issue when opening URLs that direct to the post viewer activity.
This works perfectly. Tapping a link such as https://url/.. opens the dialog and lists only one option When selecting the app, it opens the proper activity perfectly.
Here's where it gets weird. When clicking a URL such as https://url/../posts/.. the Android System sees both activity deep links as feasible. My question is how do I get around this? Changing the URL scheme is out, and I'm not fluent enough about deep links to figure out a workaround.
In ProfileActivity android:pathPattern="/..*" equals to /..*/posts/..* because an asterisk ('*') matches a sequence of 0 to many occurrences of the immediately preceding character. Try to use escape character \ as explained in docs

Deep linking in Android - Chrome does not launch #intent links

I've been trying to use deep linking from a website I own to a resource inside my app. I've been reading about how things has evolved with deep linking in Android, particularly Paul Kinlan's blog post which seems to be the most recent explanation on how things should work.
I also have read this discussion on why custom scheme is a bad practice and should not be used, which made sense.
Now I decided to use the #intent link in my website to open the resource in the app when user taps on the link. For this, I used a link like this:
intent:#Intent;package=com.example.project;component=com.example.project/.ui.ActivityWithResource;i.res_id=80;end
But when I click on it, nothing happens, and I see this in the logs:
chromium: [INFO:CONSOLE(0)] "Navigation is blocked: intent:#Intent;package=com.example.project;component=com.example.project/.ui.ActivityWithResource;i.res_id=80;end", source: http://example.com/?res_id=80 (0)
I then read about this on Chrome documentation, which interestingly, their example was using a custom scheme, contrary to what they had argued before should not be done!
Now if I add the HTTP scheme to my intent link, like this:
intent://example.com/?res_id=80#Intent;scheme=http;package=com.example.project;component=com.example.project/.ui.ActivityWithResource;end
Then it works, because the activity has the intent-filter to handle the urls like http://example.com/, but why when I specify the component, it doesn't work?
Also, when I use HTTP scheme in my intent, in shows activity resolver (except android 6.0 as I do use auto-verify), but I assume if I can get my explicit intent link to work, it should directly open the resource in the app, as I already have defined the component in the intent link. right?
Maybe the only way is to use custom scheme after all?
Thanks
P.S: Here is the activity definition in my AndroidManifest. I wasn't sure if it requires android:pathPrefix to work or not, so I added both intent-filters
<activity
android:name=".ui.ActivityWithResource"
android:label="#string/app_name"
android:exported="true"
android:screenOrientation="portrait">
<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:scheme="http" android:host="example.com" android:pathPrefix="/"/>
</intent-filter>
<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:scheme="http" android:host="example.com"/>
</intent-filter>
</activity>

open Url in android in web browser application

I am working on a Web browser. The web browser is working, but I need help in the part where my Application catches Android system's url when clicked (http,https etc) and open my web browser application
Like any other browser chrome ,firefox etc, how these app open the default app choose menu?
Reading about these I learn about <intent-filter> is used
Can someone help me with what to be added to Manifest file and to my activity so that my Application catches url?
Try adding CATEGORY_BROWSABLE to your activity that can handle URLs.
Like this:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<!--This makes activity an option for the default action (center press) to perform
on a piece of data. -->
<category android:name="android.intent.category.DEFAULT" />
<!-- Activities that can be safely invoked from a browser must support this category. -->
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http" />
<data
android:scheme="https" />
</intent-filter>

Categories

Resources