Flutter deep link parameter - android

I need to open a deep link in my Android app, like uniqueName://post/detail/1 in the router but it always removes the first part of the link: (post) and delegates only the rest: /detail/1 instead of /post/detail/1
AndroidManifest.xml:
<intent-filter android:priority="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="uniqueName"/>
</intent-filter>
onGenerateRoute:
Route? onGenerateRoute(RouteSettings settings) {
print('Change main route to: ${settings.name}');// prints /detail/1
}
Test:
adb shell am start -a android.intent.action.VIEW
-c android.intent.category.BROWSABLE
-d "uniqueName://post/detail/1"

Related

Android deep links - Multiple re-direct with same url

In my application i am using deep links to navigate to Particular activity. I want to navigate to different activities with same basePrefix with different context path at end.
<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"
android:host="www.mycompany.com"
android:pathPrefix="/profile/friendslist"/>
</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"/>
<data android:scheme="https"
android:host="www.mycompany.com"
android:pathPrefix="/profile/friendslist/details"/>
</intent-filter>
./adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://www.mycompany.com//profile/friendslist" com.mycompany.sample : It launches FriendsListFragment
./adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://www.mycompany.com//profile/friendslist/details" com.mycompany.sample : It also launches FriendsListFragment instead of FriendsListDetailsFragment
What i want to do is
/profile/friendslist/: should open FriendsList
/profile/friendslist/details?id=1234 should navigate to FriendDetails
Anyone suggest how we make use of android:pathPrefix to navigate to different screens based on context path?
You may opt for a pathPattern in the first 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"/>
<data android:scheme="https"
android:host="www.mycompany.com"
android:pathPattern="/profile/friendslist$"/>
</intent-filter>
The $ indicates end of string, which would drop the "/profile/friendslist/details" case
OR Rather, go for android:path="/profile/friendslist" which looks for an exact match.

Deep linking with Query Parameter

I have this link which I want to link a specific activity on clicking this url.
I am able to link "http://example.com" to my application, but when I tried using this query parameter in the path prefix, it returned nothing.
I use this intent-filter to link my url :
<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="example.com"
android:scheme="http"
android:pathPrefix="/"/>
</intent-filter>
Here I don't know what is the path prefix for my Url.
It does not solve your problem, but to test your URL try this ADB command:
adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://example.com?path_resolution=xyz&city=abc"'

Trying to enable deep linking to android app, testing intent can't launch activity

I'm trying to enable deep linking so that certain links launch my app.
I read this turotial https://developer.android.com/training/app-indexing/deep-linking.html and following it pretty close but when I try to test it by using adb to send the VIEW intent to the app I just get the error
Error: Activity not started, unable to resolve Intent { act=android.intent.actio
n.VIEW dat=example://gizmos flg=0x10000000 pkg=com.myapp.DeepLinkActivity }
DeepLinkActivity.java
public class DeepLinkActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getAction() == Intent.ACTION_VIEW) {
Uri uri = getIntent().getData();
}
}
}
Android Manifest declaring deeplink activity
<activity android:name="com.myapp.DeepLinkActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="gizmos"
android:scheme="example" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="www.example.com"
android:pathPrefix="gizmos"
android:scheme="http" />
</intent-filter>
</activity>
ADB command to send the view intent
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp.DeepLinkActivity
But I don't think I even need the full path to the activity
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp
Try skipping package param entirely. I had exactly same problem and it works.
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos"
Comment out the second data part from your Android Manifest. As per google documentation of deep link :
"Intent filters may only contain a single data element for a URI pattern. Create separate intent filters to capture additional URI patterns."
In your manifest you defined your scheme as "http" but in your intent constructor you are using "example."
The problem is you have one intent filter for 2 types of deep links:
<activity
android:name="app.myActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos”-->
<data
android:host="gizmos"
android:scheme="example" />
</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" />
<data
android:host="www.example.com"
android:pathPrefix="/gizmos"
android:scheme="http" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
</activity>
And you will be able to use both on the ADB shell. Please see my full answer here
Simply try as follows
Command:
adb shell am start -d your-deep-link
Example:
adb shell am start -d rmagazine://opensetting/v1

Have an Android app react to deep link

I'm trying to make my android app react to a specific deep link format. I want the app to be able to handle links in the following format:
href="android-app://website.org/http/a_path"
I have the following in my manifest file:
<intent-filter android:label="App" >
<action android:name="android.intent.action.VIEW" />
<data
android:host="website.org"
android:scheme="http" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
When I test it from the console, the app reacts to the following deeplink:
adb shell am start -a android.intent.action.VIEW -d "http://website.org/http/a_path" website.org
But it does not react to the format that I need, which is:
adb shell am start -a android.intent.action.VIEW -d "android-app://website.org/http/a_path" website.org
In this second case, I get the following error:
Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=http://org.website/http/a_path flg=0x10000000 pkg=website.org }
Any help is appreciated. Thanks!
You need to correctly set your scheme.
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="android-app"></data>
</intent-filter>
I do not see you having filter for android-app scheme:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data
android:host="website.org"
android:scheme="android-app" />
</intent-filter>
But anyway, do not use custom schemes. See this discussion involving android framework developer: https://groups.google.com/forum/#!topic/android-developers/-hkq8-S5-Gs

Android deep linking doesn't launch app

I'm pulling my hair out over this; the instructions seemed so simple, yet they just don't work.
Here's the manifest activity intent code:
<activity
android:theme="#style/Theme.Buhzyellowtoplighttabs"
android:name="com.blah.package"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="adjustResize|stateHidden"
android:screenOrientation="portrait" >
<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" android:host="www.buhz.com" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
So you would think that when I run the app on my phone, go to my browser and go to www.buhz.com it should give me a option to launch the app, right?
As far as I'm aware, this will only work when you click a link to the site, not when you type the URL in.
On the off-chance you're reading this on the Android device your testing on, here is a link for you
Here is the approach that worked for me
The androidmanifest file content is as follows:
<activity
android:name=".SecondActivity"
android:label="#string/title_activity_second">
<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="www.example.com"
android:pathPrefix="/roses"
android:scheme="http" />
</intent-filter>
</activity>
The command entered in terminal is as follows :
./adb shell am start -a android.intent.action.VIEW -d "http://www.example.com/roses" com.example.irfan.helloworld
Note:
If your operating system is Windows you can remove the first "./" in the above command.
Result:
It opened the "Second Activity" of my app automatically.
Hope it helps :)
For me:
adb shell am start  -W -a android.intent.action.VIEW  -d "example://gizmos" com.example
didn't work.
Adding category solved it:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://www.example.com/gizmos"

Categories

Resources