Reputation: 85
Looking at https://developer.chrome.com/multidevice/android/intents What is then the best way to get result back to Chrome browser from app? There is browser_fallback_url but is there any kind of result_callback handler? Question is similar to How to get a result back to your web page from an Intent triggered from inside Chrome?
Edit: Started issue for this https://code.google.com/p/chromium/issues/detail?id=572067
Upvotes: 5
Views: 4403
Reputation: 16607
Chrome doesn't start the Activity with startActivityForResult
so there is no simple method for the receiving App to callback directly into the web site or web app with a response as you would expect natively.
There is a solution though but it requires the native app to agree to the protocol.
The ZXing QR Code Scanner supports a callback into the site with result of the QR code scan using a simple Query String Parameter called ret
On Android, you can invoke Barcode Scanner from a web page and have the result returned to your site via a callback URL. For example, when 01234 is scanned, to have the user return to http://foo.com/products/01234/description, simply link to a URL like this, where {CODE} is a placeholder for the value of the returned code:
Note that the URL in the ret= parameter is URL-escaped, and that {CODE} is used as a placeholder for the scanned value (above, it appears as %7BCODE%7D). SCAN_FORMATS, and other parameters, can be set here as well to control the scan behavior. For example is can be used to supply a comma-separated list of format names.
You can set up a similar scheme inside your native app and web app so that when the action is completed in the native app and it was started with a query string parameter called ret
(or whatever you want) then it knows it needs to start a new Activity with the callback URL set in the Intent and the extra data added in the query string, this way your browser will then open with all the data that it needs.
It does have a number of issues though:
Upvotes: 1