I'm struggling to get a specific behavior for OAuth authorization using the ubiquitous callback with custom scheme->intent_filter technique.
My app registers for SEND actions and, when called, starts a service which, in turn, checks if the user is already authorized and, if not, spawns an activity (OAuthActivity) to request login.
Keep in mind that the foreground activity right before this happens may be anything. The activity then starts a VIEW intent to open the auth page in the browser; the latter invokes the crafted callback (with custom scheme defined in manifest) and wakes the OAuthActivity.
OAuthActivity has, currently, launchMode="singleTask"
but this doesn't make a difference from stack perspective (it gets on top when called back).
Is there a way I can clear the activity stack and get back to what the user was doing and not force him push 'back' on the browser activity? (I'll then show a notification when the content was successfully submitted in the background)
Does anyone have any pointers? Thanks for reading through
The activity then starts a VIEW intent to open the auth page in the browser
That's the problem. This works for me: render the oauth web page in a webview you control rather than launching out to the browser app.
The oauth web page, when it calls its callback, will actually be replacing itself in the webview, where your WebViewClient can catch that expected URL, process the results, and finish() the webview (removing it from the activity stack).
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