Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What makes Google Maps/Youtube able to display the 'Complete this action with' menu?

Tags:

android

And if possible, how can I get this behavior for 'my' app?

For example, when a user navigates to the URL 'example.com/*' (any page starting with example.com), I'd want it so the 'complete this action with' menu shows up listing all of the browsers and this particular app?

I've done some reading of the Intent documentation, but it seems like you can only create them for phone data, not web URLs.

Edit: anyone? I've looked into this some more, but haven't had any luck. I'd like to set a bounty, but I don't have that option yet. If it isn't possible, I guess I'll just make a way to paste in a URL.

like image 776
Nate Parsons Avatar asked Feb 03 '11 05:02

Nate Parsons


1 Answers

It's pretty simple, actually! What you want is an intent filter with the BROWSABLE category set, and a <data> tag set up to match your URL.

Inside your <activity>, add:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="http" android:host="www.example.com" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

and set up the action and categories how you want, and change the data tag values to something relevant to your application. This will allow your link (in this case, http://www.example.com/) to be launched in your application by the browser.

like image 110
Jess Avatar answered Oct 13 '22 11:10

Jess