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?
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.
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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With