Android WebView shows blank screen

╄→гoц情女王★ 提交于 2020-01-05 08:32:20

问题


I'm trying to create a WebView app that shows a meteor web app using Tiago Scolari's sample. When i load the apk in my phone i see the background changes but the log in button doesn't show.

Anyone has a clue how to make this work?

--Edit: Adding -

webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setDomStorageEnabled(true);

- shows me the log in button and gets me to the facebook log in. After logging in using facebook i'm presented with a white screen. Any more advice?

Some code: main.xml (layout):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <WebView android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/mainWebView">
    </WebView>
</LinearLayout>

AndroidMobileAppSample.java (java wrapper):

package tscolari.mobile_sample;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class AndroidMobileAppSampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        WebView mainWebView = (WebView) findViewById(R.id.mainWebView);

        WebSettings webSettings = mainWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setDomStorageEnabled(true);

        mainWebView.setWebViewClient(new MyCustomWebViewClient());
        mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

        mainWebView.loadUrl("http://pastime.meteor.com/");
    }

    private class MyCustomWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }
    }
}

回答1:


oke I just tested it on my 2.3.4 android and yea there is no facebooklogin. Its a WebView problem. Changed the code and still the login dosent appear...



来源:https://stackoverflow.com/questions/18378799/android-webview-shows-blank-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!