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 Web
The Application cannot find out if user has finished with ban page or not. usually bank payment gateways called with a callBackUrl attribute.
i handle this situation like this:
Html Page:
<div class="flex-center position-ref" style='height:30vh;'>
<a href="http://myserver/app/order/payed" class="btn-success">
Return To Application
</a>
</div>
in Android Manifest:
<activity
android:name=".shop.customer.order.OrderPayedActivity"
android:launchMode="singleInstance"
android:taskAffinity=".shop.customer.cart.CartActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="@string/BASE_URL_HOST"
android:pathPattern="/app/order/payed"
android:scheme="@string/BASE_URL_SCHEME" />
</intent-filter>
</activity>
and in The Receiving Activity:
//managed parent activities in the manifest in order to make task`s back stack
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this,OrderListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);
taskStackBuilder.addNextIntentWithParentStack(intent);
taskStackBuilder.startActivities();
//startActivity(intent);
finish();
}
Actually you are able to return to your calling activity taking a different approach. If the webpage you are calling is handled by you or allows you to assign a callback when the user finishes doing dome processing, then you can set that callback to a URI, and assign that URI to your calling activity, if the activity launch mode is singleTask, then you're going to be able to resume your activity.
The only thing that I haven't resolved is that I don't know how to remove the browser from the stack once it returns to your calling activity. I want to accomplish this because once you leave your app, android pops the browser activity to the front, forcing the user to finish it by himself.
Just put a ResultCode argument on your startActivityForResult method, something like =this.startActivityForResult(intent, PAYMENT_ACCEPTED)
It will be returned as resultCode when you finish your second activity.
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.