我做验证了这是应该重定向到我的应用程序与身份验证令牌(OAUTH)第三方网站。
I am doing authentication with a third-party site that's supposed to redirect back to my app with auth token (OAUTH).
我有回调的正常工作,如果我通过
I have the callback working properly if I open the 3rd party site in a separate browser process via
this.startActivity(new Intent(Intent.ACTION_VIEW, uri));
但是,如果我嵌入的WebView组件在我的布局,并打开URL在于,回调不工作。的WebView说,您没有权限打开的myapp://回调令牌= ...并迅速刷新,找不到网页......暂时关闭......等等等等
but, if I embed a WebView component in my layout, and open the url in that, the callback does not work. Webview says "You do not have permission to open myapp://callback?token=...." and quickly refreshes to "Web page not available...temporarily down...blah blah"
任何想法?
您需要实现一个 WebViewClient 加载之前就拦截了自定义的URI。 的你好,的WebView教程显示了一个简单的例子。他们有:
You need to implement a WebViewClient to intercept the custom URI before it is loaded. The Hello, WebView tutorial shows a simple example. Where they have:
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
您可以更改view.loadUrl(URL),以检查URL是否是你的自定义URL和处理它不过你想要的。
You can change "view.loadUrl(url)" to check if the URL is your custom URL and handle it however you want.