1

I've created an app that opens when clicking a specific URL. Obviously I've got something like this:

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

So that's all great, whenever somebody clicks a link with http://example.com/whatever/stuff... it'll open my app. However, within my app, after doing some stuff, I want to send the suer back to the default browser (or whichever browser/web view they were using when they clicked the link to begin with). My problem is that I end up creating a loop:

  1. User clicks link http://example.com/xxx and my app opens.
  2. My app does stuff, and now wants to send the user to a different URL, eg. http://example.com/yyy
  3. The intent that my app sends, ends up just going back to itself (my app).

    Intent httpIntent = new Intent(Intent.ACTION_VIEW);
    String theNewURL = http://example.com/yyy;
    httpIntent.setData(Uri.parse(theNewURL));
    startActivity(httpIntent);
    

How can I get my httpIntent to use the default browser (or wherever the user came from to begin with) instead of calling my app again?

Edit: I've been able to solve the problem in a make-shift way, by making a CNAME record of one of my own domains (as a sort of alias) that goes to the same spot as http://example.com. It sucks because the user now sees a different URL, but it still works in that it doesn't invoke the intent. (Am I even using the right language when I talk about intents?)

ajwest
  • 258
  • 7
  • 17

1 Answers1

-1
Intent HttpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com/yyy"));

startActivity(HttpIntent); 
DJPlayer
  • 3,244
  • 2
  • 33
  • 40
  • I've already done this. As I say, my app listens for `http://example.com/anything` and ends up calling itself when it's set as the default action. Otherwise the menu pops up and asks what the user wants to do with it. Either way, I want it to use the browser, not my app. – ajwest Oct 14 '11 at 19:40
  • what OS version are you testing this on? There are some strange variances that cause it to work/not work. Strange enough some people use: final Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)); activity.startActivity(intent); – DJPlayer Oct 14 '11 at 19:45
  • I'm using a Nexus One with CM 7.1.0 (Android 2.3.7). But either way, the only difference I see with that is the inclusion of a `final` and the fact that it's all in one line instead. This is still relaunching my app. I'll try it on the emulator with a different version though. – ajwest Oct 14 '11 at 20:02