Reputation: 1236
Deep Linking not working in android. I have pasted my manifest code here. When I tested, it goes to the website and not opening my activity in my app. Can someone help me fix this?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.clinicloud.app" >
<application
android:name=".MainApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<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.XXXX.com"
android:pathPrefix="/xyz"
android:scheme="http"/>
</intent-filter>
</activity>
<activity
android:name=".OnboardingActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ProfileViewActivity"
android:label="@string/title_activity_profile_view"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
</application>
</manifest>
UPDATE:
adb shell am start -W -a android.intent.action.VIEW -d "http://www.clinicloud.com/xyz" com.clinicloud.app
Testing with adb opens the app but just with browser its not opening the app.
Upvotes: 9
Views: 14231
Reputation: 349
This will only work if server has /.well-known/assetlinks.json properly defined in the root domain on the server.
So you need to create a json file and define there package name and SHA256. Then guys from backend should put this json file into root domain on the server.
The content of the file looks like:
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "com.blablabla.staging",
"sha256_cert_fingerprints": ["XXXXXXXXXXXXXXXXXXX"]
}
}
]
You can split it for different environments: staging, beta, prod etc.
I tested in default browser of Samsung “Internet” and it fired the deeplink!
Upvotes: 3
Reputation: 4497
It's so annoying to test deep link through adb as the Android Developer team suggested. We won't get the gist of the problem I think. We want a straight forward method like paste a link to the browser in the same device which also installed the app already, hit GO, then the app comes up. But unfortunately, it won't work though.
Reason:
It's not a pure link, when you go to URL search of the browser it actually does a different URL, e.g: 'https://www.google.com/search?....'
Solution: Open a pure link
As @Parag Chauhan suggested, using another app to open a link, sure it is a definitely working solution because it's a pure link. However, this is not practical as expected.
Alternatively,
2.1. You can build your own simple web page (simple file *.html) with a link, then click it to open a pure link. Here is an example of the web page:
<html>
<h1>
<a id="deeplink" href="ss.wohui.learn://subscribed">Deep Link</a>
</h1>
</html>
2.2. Replace ss.wohui.learn://subscribed
with what your deep link is.
2.3. Download the file to your device.
2.4. Open it by a browser.
2.5. Click on the Deep Link.
2.6. The app will start.
Upvotes: 4
Reputation: 35936
Add this code in Manifest.xml
<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.clinicloud.com"
android:path="/xyz"
android:scheme="http" />
</intent-filter>
For test create another project and run below code
Intent i = new Intent(
Intent.ACTION_VIEW , Uri.parse("http://www.clinicloud.com/xyz")
);
startActivity(i);
You can also pass parameter in link. For more info, see my blog post Make a link in the Android browser start up my app?
Upvotes: 1