Skip to content Skip to sidebar Skip to footer

Taking Uri Data Through Intent In Android

Hi i have to do connectivity between android app and browser. So while clicking a button on browser it should redirect to android app. in android activity i have written Uri data

Solution 1:

Quoting answer from: How to listen for a custom URI

To register a protocol in your android app, add an extra block to the AndroidManifest.xml

I modified the code a little, but thought I'd quote the source too

<manifest><application><activityandroid:name=".activityToCall"><intent-filter><actionandroid:name="android.intent.action.VIEW" /><categoryandroid:name="android.intent.category.DEFAULT" /><categoryandroid:name="android.intent.category.BROWSABLE" /><dataandroid:scheme="scheme"android:host="path"/></intent-filter></activity></application></manifest>

Then when a url matching your schema is opened your app will be called to handle it I assume. Taking into consideration that scheme and pathcorrespond to this:

scheme://host/path

After that, in the activity you've set in the manifest to handle this stuff:

Uri data = getIntent().getData(); 
if (!data.equals(null)){ 
    String scheme = data.getScheme(); 
    //Or whatever you needed
}

Post a Comment for "Taking Uri Data Through Intent In Android"