6
Android deep linking is not working
===================================
 Android link:-notification://id=notificationid

1:-In manifest

      <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                    <category android:name="android.intent.category.BROWSABLE" />

                    <data
                        android:host="id"
                        android:scheme="notification" />
                </intent-filter>       

2:-and coding side

 @Override
        protected void onResume() {
            super.onResume();        
            Intent intent = getIntent();
            String string=intent.getAction();
            Uri data = intent.getData();
            Log.d("hello","cgbdsuyfdkv");
        }   

but its not working please any body can help me !!!!!

Ashutosh Srivastava
  • 597
  • 1
  • 9
  • 13

4 Answers4

3

You can simply modify your url

Android link:-notification://id=notificationid instead of
Android link:-notification://page?id=notificationid  //page is host name
I tried a lot and find out this is working for me.
  1. manifest code

               <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.BROWSABLE" />
    
                <data
                    android:host="page"
                    android:scheme="notification" />
            </intent-filter>       
    

2.java code #get your notification id here

Intent intent = getIntent();
    String string = intent.getAction();
    Uri data = intent.getData();
    if (data != null) {
        String path = data.getPath();
        String path1 = data.getPath();
        providerUrl = intent.getData().toString();
        UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
        sanitizer.setAllowUnregisteredParamaters(true);
        sanitizer.parseUrl(providerUrl);
        String id = sanitizer.getValue("id");
        if (id != null)
            Log.d("notification id", id);
    }
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
Shiv Kumar
  • 635
  • 7
  • 13
  • yes i agree my Android link:-**notification://id=notificationid** is not correct. when i change url **notification://hostname?id=notificationid** its working fine – Ashutosh Srivastava Mar 03 '17 at 06:02
2

Add onNewIntent() method to your Activity and then use intent object which is variable in OnNewintent() method , which has updated method.

onNewIntent() is meant as entry point for singleTop or singleTask activities which already run somewhere else in the stack and therefore can't call onCreate(). From activities lifecycle point of view it's therefore needed to call onPause() before onNewIntent(). I suggest you to rewrite your activity to not use these listeners inside of onNewIntent(). For example most of the time my onNewIntent() methods simply looks like this:

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
//use this  intent object to get notificationid for second time 

}
Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43
1

1st step:

<intent-filter>
    <data android:scheme="your_uri_scheme" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

2nd step:

Uri data = this.getIntent().getData();
if (data != null && data.isHierarchical()) {
    String uri = this.getIntent().getDataString();
    Log.i("MyApp", "Deep link clicked " + uri);
}
Jared Rummler
  • 37,824
  • 19
  • 133
  • 148
0

I think you Intent Filter is incomplete

<!-- To open app using link -->
    <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="http"
              android:host="yourdomain.com"
              android:pathPrefix="/someurlparam">
        </data>
    </intent-filter>
Akshay
  • 6,029
  • 7
  • 40
  • 59