Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Webview未从数组加载url_Java_Android_Webview - Fatal编程技术网

Java Webview未从数组加载url

Java Webview未从数组加载url,java,android,webview,Java,Android,Webview,当我运行此程序时,webview不会加载,而是只显示一个白色屏幕。数组是URL的列表。Logcat显示此错误 11-06 23:36:40.879 25145-25145/live.randomize.abhi.randomize I/cr\U浏览器启动:初始化铬过程, singleProcess=false 11-06 23:36:40.888 25145-25238/live.randomize.abhi.randomize W/cr_ChildProcLauncher: 使用包名创建新的C

当我运行此程序时,webview不会加载,而是只显示一个白色屏幕。数组是URL的列表。Logcat显示此错误

11-06 23:36:40.879 25145-25145/live.randomize.abhi.randomize I/cr\U浏览器启动:初始化铬过程, singleProcess=false 11-06 23:36:40.888 25145-25238/live.randomize.abhi.randomize W/cr_ChildProcLauncher: 使用包名创建新的ChildConnectionLocator= com.android.chrome,inSandbox=true 11-06 23:36:40.912 25145-25145/live.randomize.abhi.randomize D/EGL_仿真: eglCreateContext:0xa46fdc20:maj 2 min 0 rcv 2 11-06 23:36:40.913 25145-25145/live.randomize.abhi.randomize D/EGL_仿真: eglMakeCurrent:0xa46fdc20:ver 2 0(tinfo 0xa43334d0)11-06 23:36:41.179 25145-25145/live.randomize.abhi.randomize W/合子: 尝试删除非JNI本地引用,转储线程11-06 23:36:41.195 25145-25225/live.randomize.abhi.randomize D/EGL_仿真:eglMakeCurrent:0xb45a1a40:ver 2 0(tinfo 0xa4226770)11-06 23:36:41.293 25145-25145/live.randomize.abhi.randomize W/受精卵:尝试删除 非JNI本地参考,转储线程11-06 23:36:42.652 25145-25145/live.randomize.abhi.randomize W/受精卵:尝试删除 非JNI本地参考,卸载线程11-06 23:36:42.695 25145-25145/live.randomize.abhi.randomize I/chatty:uid=10083(u0_a83) live.randomize.abhi.randomize相同的1行11-06 23:36:42.727 25145-25145/live.randomize.abhi.randomize W/受精卵:尝试删除 非JNI本地参考,转储线程11-06 23:36:42.844 25145-25145/live.randomize.abhi.randomize W/受精卵:尝试删除 非JNI本地参考,转储线程11-06 23:36:42.925 25145-25145/live.randomize.abhi.randomize I/chatty:uid=10083(u0_a83) live.randomize.abhi.randomize相同的1行11-06 23:36:42.989 25145-25145/live.randomize.abhi.randomize W/受精卵:尝试删除 非JNI本地引用,dumpin

这是代码:-有什么帮助吗?是的,我在舱单中有互联网权限

private String[] array;
private WebView myWebView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    array = getApplicationContext().getResources().getStringArray(R.array.myArray);
    final String randomStr = array[new Random().nextInt(array.length)];
    {
        myWebView = (WebView) findViewById(R.id.myWebView);
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setUseWideViewPort(true);
        myWebView.getSettings().setDomStorageEnabled(true);

        webSettings.setLoadWithOverviewMode(true);
        myWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView View, WebResourceRequest request)

            {   myWebView.loadUrl(randomStr);
                return true;
            }
        });
    }
}
用这个-

    private String[] array;
    private WebView myWebView;
    private ProgressDialog progress;;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);

        progress = new ProgressDialog(TestActivity.this);
        progress.setTitle("Loading");
        progress.setMessage("Wait until site has finished loading.");
        progress.setCancelable(true);
        progress.show();

        myWebView = (WebView) findViewById(R.id.myWebView);
        array = getApplicationContext().getResources().getStringArray(R.array.myArray);
        final String randomStr = array[new Random().nextInt(array.length)];

        Log.d("TAG: ", randomStr);

        myWebView.getSettings().setJavaScriptEnabled(true);
        myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        myWebView.getSettings().setSupportMultipleWindows(true);
        myWebView.loadUrl(randomStr);

        myWebView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                if(progress.isShowing()){
                    progress.cancel();
                }
            }
        });
    }