1

I have an android app that is opened through a intent on a webpage. This app does few things and when it finishes I want to come back on browser on another page. I can do that but it opens a new tab while I would like to change page without open a new tab.

This is what I do:

            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(callbackUrl));
            startActivity(browserIntent);
            MainActivity.this.finish();

Is there a way to do this?

Thanks

  • Show the code that produces this. Each question should be accompanied with a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – nya Aug 22 '16 at 15:12

1 Answers1

0

I couldn't find any information how to change data in the original browser (and it doesn't seem a reasonable action) but here what you can do:

  • On your webpage generate a session_id (user_id/whatever_id) and store it somewhere (cookies, local storage, or just in memory)
  • When launching intent pass this id along (<a href="my.special.scheme://session_id">)
  • Get this id in the app like described here
  • Then you'll have to make a simple web app which will save a pair: id - URL and will invalidate it after first get request
  • When you want get back to browser and redirect send to the mentioned server this URL (e.g. myserver.net/store?id=<session_id_here>&url=google.com)
  • Then simply 'go back' to browser
  • When your webpage regains active get this and ask server if there are any URL for it (e.g. myserver.net/get?id=<session_id_here>)
  • Get this url and go to it (window.location.href = <url>)
Community
  • 1
  • 1
Teivaz
  • 4,616
  • 4
  • 25
  • 63
  • It can be an option. I thought of a job that waits for a response from the android app and when it comes the page is reloaded on the link I want. I don't like it very much I still hope for a better solution. Thanks. – Marco Reply Aug 23 '16 at 08:14