Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Intent-Filter for http address

I am trying to intercept a couple different links with my app, and I am having trouble with the intent-filter data parameters to do it.

Here are the 2 types of links that I want to intercept

  1. http://www.domain.com/#id=abcdef123346
  2. http://www.domain.com/social/landing/abcdef123456

I have already decided to have a separate activity to intercept both links and use java regex to start the correct activity. However I can't seem to capture just these two formats without capturing something like http://www.domain.com/abc123

<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.domain.com"
                android:pathPattern="/#id.*" />
        </intent-filter>

This is what I am currently trying to intercept type 1 and for some reason it isn't working.

This intent-filter correctly intercepts type 2

<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" />
            <data android:host="domain.com" />
            <data android:host="www.domain.com" />
            <data android:pathPrefix="/share/web" />
            <data android:pathPrefix="/social/landing" />
        </intent-filter>

Thanks,

like image 642
Leo Avatar asked May 30 '11 18:05

Leo


People also ask

How do I open a URL with intent?

To open a URL/website you do the following: String url = "http://www.example.com"; Intent i = new Intent(Intent. ACTION_VIEW); i.

What does the intent filter do in Android?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.

Is intent deprecated?

content. intent' is deprecated. I found some threads regarding the usage of getIntent() but I am creating a new intent in my case in a RecyclerViewAdapter to open a new Activity.

How do I find deep links on Android?

By using Android Debug Bridge (ADB) shell commands one can test the deep link flow. It is used to verify if the link navigates to the correct section of your app. This command starts the ADB shell with the VIEW action and specifies the deep link URL to be tested.


1 Answers

I think that the string that pathPattern is matching is "/", and "#id..." is omitted because it is part of the fragment. If you used http://www.domain.com/id/abcdef123456 instead, pathPattern could match "/id/.*" because it is part of the path.

like image 200
user775598 Avatar answered Sep 22 '22 20:09

user775598