我正在尝试通过Facebook和谷歌登录webapp,虽然Facebook登录工作正常,我不知道谷歌登录出了什么问题。 输入谷歌ID和密码后,我得到一个空屏幕 这是我的代码 -
rlContainer= (RelativeLayout) view.findViewById(R.id.rlContainer);
wbWebView= (WebView) view.findViewById(R.id.wbWebViews);
wbWebView.getSettings().setJavaScriptEnabled(true);
wbWebView.getSettings().setAllowFileAccess(true);
wbWebView.getSettings().setDomStorageEnabled(true);
wbWebView.getSettings().setDatabaseEnabled(true);
wbWebView.getSettings().setSupportMultipleWindows(true);
wbWebView.setWebViewClient(new MyBrowser());
wbWebView.setWebChromeClient(new PQChromeClient());
private class MyBrowser extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(android.webkit.WebView view, String url) {
String host = Uri.parse(url).getHost();
//Log.d("shouldOverrideUrlLoading", url);
if (host.equals(Constants.TARGET_Prefix))
{
if(mWebviewPop!=null)
{
mWebviewPop.setVisibility(View.GONE);
rlContainer.removeView(mWebviewPop);
mWebviewPop=null;
}
return false;
}
if(host.equals("m.facebook.com")||host.equals("mobile.facebook.com")||host.equals("accounts.google.com"))
{
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
Log.d("onReceivedSslError", "onReceivedSslError");
//super.onReceivedSslError(view, handler, error);
}}
public class PQChromeClient extends WebChromeClient {
@Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
mWebviewPop = new WebView(getContext());
mWebviewPop.setVerticalScrollBarEnabled(false);
mWebviewPop.setHorizontalScrollBarEnabled(false);
mWebviewPop.setWebViewClient(new MyBrowser());
mWebviewPop.getSettings().setJavaScriptEnabled(true);
//mWebviewPop.getSettings().setSavePassword(false);
mWebviewPop.getSettings().setDomStorageEnabled(true);
mWebviewPop.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
rlContainer.addView(mWebviewPop);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(mWebviewPop);
resultMsg.sendToTarget();
return true;
}
@Override
public void onCloseWindow(WebView window) {
Log.d("onCloseWindow", "called");
}}
有人可以解释一下我做错了什么吗?