Intent Filter passing data through url and reading

2019-09-12 10:45发布

问题:

In my app, I need to open one page from out side app, through link which is in email.

In my app when some one will create post from our website then we are sending email with url.

When user will click on url/link then it will open respective page in the app.

I need to pass some id and other value to the activity when it launch.

Example:

we are sending following link through email when some one create post on website.

https://www.example.com/lt-url-redirector.php?user_guid=4074395&notify_entity_id=7221752&notification_type=22&notify_id=56933b6219b05172&baseurl=https://www.example.com/groups/calendar/aggregation/mlt

After clicking on above link it goes to mobile browser where "Open in App" button is there.

After taping on this button it gives:

window.location.href = 'abcdef:/?user_guid=4074395&notify_entity_id=7221752&notification_type=22&notify_id=56933b6219b05172&baseurl=https://www.example.com/groups/calendar/aggregation/mlt';

I want to pass notify_entity_id, notification_type, notify_id etc to the activity when it launch.

Android Manifest code :

<intent-filter>
            <data android:scheme="abcdef" />

            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>

回答1:

Those are query parameters, and there are a variety of methods on Uri for retrieving those values, such as getQueryParameters(). To get the Uri, call getIntent().getData() from some likely spot, such as onCreate() of your activity.