Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deep Linking from browser not working Android

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.

like image 292
User Avatar asked Oct 31 '22 15:10

User


2 Answers

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

  1. 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.

  2. 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.

like image 182
Nguyen Tan Dat Avatar answered Nov 15 '22 04:11

Nguyen Tan Dat


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?

like image 29
Parag Chauhan Avatar answered Nov 15 '22 06:11

Parag Chauhan