0

Possible Duplicate:
Android Respond To URL in Intent

If I click on a link for Twitter (twitter.com), Yelp (yelp.com), or Google Maps (maps.google.com), my phone asks me if I want to handle it in the browser or in the application.

I've found plenty of material on how to set up a custom protocol on Android, but not on how to get it to recognize certain URL paths as belonging to an application.

Basically, I want it set up so if a user goes to http://foo.org/myfooapp/whatever it launches myfooapp and sends it all or part of the url.

Also, I don't have an iPhone, so I'm wondering if there's a similar behavior in iOS, where you click on a web link for Twitter, Yelp, etc. and it offers you the choice of viewing that URL in the custom app.

Clarification

Here is what I want to know how to make happen:

  1. Someone clicks on a link http://myapp.example.org/, while in a browser or anywhere one could click a link
  2. Instead of just loading the link in a browser, the phone pops up the following dialog:

    COMPLETE ACTION USING:

    • Browser
    • MyApp [ ] Use by default for this action

To see what I mean, go to http://maps.google.com on any Android phone (assuming you have Google Maps installed). It will ask you whether you want to use the browser or the Google Maps application.

Oh! Also, I want to know if iOS has a similar option.

4

1 Answer 1

1

You will achieve this result if your app has a BroadcastReceiver that listens for Intent.ACTION_VIEW on the particular URI. You should use an IntentFilter so that you do not receive that broadcast for every intent of the particular action. In particular your IntentFilter should filter based on the data scheme. The docs on IntentFilter elaborate.

I have not tested this though.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.