Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting an ACTION_VIEW activity to open the browser, how do I return to my app?

Tags:

android

In my app i need to open the bank's page, to make the user able to pay. Reading the Android documentation I see that I should use an ACTION_VIEW (and not a WebView) to accomplish this.

 Uri uri = Uri.parse("http://www.example.com");
 Intent intent = new Intent(Intent.ACTION_VIEW, uri);
 startActivity(intent);

My question is: After the user is done with the payment, how can i get back to the app?

I mean, I'd like to do something like

startActivityForResult(intent, RESULT_CODE);

to open the bank's site, and then get back to the app when the user is done, using the

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

callback to handle the result of the payment.

And, am I following the right way? Or is there any other way to accomplish this?

like image 746
Abramodj Avatar asked Mar 09 '11 16:03

Abramodj


People also ask

What is start activity in Android?

Starting activities or services. To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent.

How do I open activity from another app?

If both application have the same signature (meaning that both APPS are yours and signed with the same key), you can call your other app activity as follows: Intent LaunchIntent = getActivity(). getPackageManager(). getLaunchIntentForPackage(CALC_PACKAGE_NAME); startActivity(LaunchIntent);


1 Answers

How would the browser know that user is done with the bank page? It has no way to know that.

Also, browser does not react to startActivityForResult() by setting result and then finish().

So, you can not use Android browser to accomplish this task.

The only possible way would be to start WebView and to detect when user is finished, by detecting certain url that is (supposedly) shown when user is finished with the bank task.

like image 192
Peter Knego Avatar answered Nov 15 '22 20:11

Peter Knego