浏览器回调和Android的活动栈疯狂 [英] Browser callbacks and Android Activity stack madness

查看:182
本文介绍了浏览器回调和Android的活动栈疯狂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挣扎利用无处不在的回调定制计划─> intent_filter技术来获取OAuth的授权特定的行为。

我的应用程序寄存器发送动作,被调用时启动,反过来,检查用户已经授权的服务,如果没有,会生成一个活动(OAuthActivity)请登录。

请记住,正确的在此之前的前台活动发生可能是任何东西。活动然后开始一个VIEW意图打开浏览器中的身份验证页面;后者调用制作的回调(在清单中定义自定义方案),并唤醒OAuthActivity。

OAuthActivity了,目前, launchMode =singleTask但是这并没有使从堆栈的角度(它会在上面的时候叫回来)的​​差异。

有没有一种方法,我可以清除活性堆栈并取回什么用户在做什么,而不是强迫他按后退在浏览器上的活动? (我会再展的通知时已成功提交的背景内容)

有没有人有任何指针?感谢您通过

阅读
解决方案
  

活动,然后开始一个VIEW意图在浏览器中打开AUTH页

这就是问题所在。这个工作对我来说:渲染OAuth的网页在一个web视图可以控制,而不是启动了浏览器的应用程序

OAuth的网页,当它所谓的回调,实际上是代替自己在web视图,在这里你WebViewClient能赶上预期的URL,处理结果,并完成()的web视图(从活动堆栈中取出) 。

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).

这篇关于浏览器回调和Android的活动栈疯狂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆