Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Deep Linking for App content Android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 229
    Comment on it

    Deep Linking enable user to enter into app from Search.

    For enable Deep Linking we must add intent filters for the relevant activities in application manifest. These intent filters allow deep linking to the content in any activity of application.

    Add Intent Filter with below elements and attribute values in manifest.

    < action> :- add ACTION_VIEW so that activity reach by Google Search.
    <category> :- add CATEGORY_BROWSEABLE so that app can access from browser.
    <category> :- add CATEGORY_DEFAULT because if app will not found in device then default action will fire. <data> :- meta data about deep linking.

    inside data tag these tags are added.

                    android:host="developer.android.com"
                    android:pathPrefix="/training"
                    android:scheme="http"   
    

    These Tag accepts URIs that begin with "developer.android.com/training

    Intent Filter work is done now. Now Read data from incoming Intent

    Get Intent from Activity and render incoming data.

    Example Code:-

    Android Manifest :-

      <!--  Intent filter for Deep Linking -->
                <intent-filter>
                    <data
                        android:host="developer.android.com"
                        android:pathPrefix="/training"
                        android:scheme="http" />
    
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
    

    Activity Code:-

       Intent intent = getIntent();
            String action = intent.getAction();
            Uri data = intent.getData();
    
            Toast.makeText(this, data.toString(), Toast.LENGTH_LONG).show();
    

    NOTE:-The leading "/" is required for pathPrefix

    Screen:-

    alt text alt text

    Happy Coding !!

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: