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.

Community
  • 1
  • 1
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
  • possible duplicate of [Is there a list of iOS apps that can be called using custom URLs?](http://stackoverflow.com/questions/6058585/is-there-a-list-of-ios-apps-that-can-be-called-using-custom-urls) – progrmr Dec 02 '11 at 16:53
  • 1
    Not a duplicate of that question, for two reasons: 1) iOS is an aside; my primary interest is for the Android and, more importantly, 2) That question is asking for a list of apps that use custom schemes which is **totally unrelated**. – Jordan Reiter Dec 02 '11 at 19:09
  • possible duplicate of [Android Respond To URL in Intent](http://stackoverflow.com/questions/525063/android-respond-to-url-in-intent) – Jordan Reiter Dec 02 '11 at 21:13
  • Possible duplicate of [Android Respond To URL in Intent](https://stackoverflow.com/questions/525063/android-respond-to-url-in-intent) – Cœur Jul 14 '18 at 11:49

1 Answers1

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.

Neil
  • 2,316
  • 1
  • 22
  • 26