您必须在验证时检查浏览器的回调 url,然后它会重定向到主页。用这个,
browser.setWebViewClient(new TwitterWebViewClient());
private class TwitterWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d(TAG, "Redirecting URL " + url);
if (url.startsWith(CALLBACK_URL)) {
browser.loadUrl(TWITTER_HOME_URL);
return true;
} else if (url.startsWith("authorize")) {
return false;
}
return true;
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { }
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) { }
@Override
public void onPageFinished(WebView view, String url) { }
}