Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?)

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
Intent HttpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com/yyy"));

startActivity(HttpIntent); 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2013 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.12.6.1206\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflo", "ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2013 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.12.6.1206\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscript>\r\n<script type=\"text/javascript\">var p = \"http\", d = \"static\"; if (document.location.protocol == \"https:\") { p += \"s\"; d = \"engine\"; } var"], "copyright__copyright__copyright": ["ent. (Am I even using the right language when I talk about intents?)\n\nshare|improve this question\nadd comment\n\n1 Answer\n\nup vote 0 down vote accepted\nIntent HttpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(\"http://example.com/yyy\"));\n\nstartActivity(HttpIntent); \nshare|improve this answer\nadd comment\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}