Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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 当url包含http时,在设置WebViewCore之前不支持Android:removeMessages(int what=107)_Java_Android_Exception_View_Web - Fatal编程技术网

Java 当url包含http时,在设置WebViewCore之前不支持Android:removeMessages(int what=107)

Java 当url包含http时,在设置WebViewCore之前不支持Android:removeMessages(int what=107),java,android,exception,view,web,Java,Android,Exception,View,Web,我写了一个简单的程序,可以直接将网页加载到web视图中 URL包含http://并且web视图工作得很好,除了这个恼人的107错误之外,大多数ppl认为这是因为您的URL不包含http头 我在网上到处搜索,找不到和我的案子类似的东西 06-13 09:12:25.259: W/webcore(656): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewC

我写了一个简单的程序,可以直接将网页加载到web视图中

URL包含http://并且web视图工作得很好,除了这个恼人的107错误之外,大多数ppl认为这是因为您的URL不包含http头

我在网上到处搜索,找不到和我的案子类似的东西

06-13 09:12:25.259: W/webcore(656): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
06-13 09:12:25.259: W/webcore(656):     at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1683)
06-13 09:12:25.259: W/webcore(656):     at android.webkit.WebViewCore$EventHub.access$7900(WebViewCore.java:926)
06-13 09:12:25.259: W/webcore(656):     at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1795)
06-13 09:12:25.259: W/webcore(656):     at android.webkit.WebView.sendOurVisibleRect(WebView.java:2917)
06-13 09:12:25.259: W/webcore(656):     at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:593)
06-13 09:12:25.259: W/webcore(656):     at android.webkit.ZoomManager.access$1700(ZoomManager.java:49)
06-13 09:12:25.259: W/webcore(656):     at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:984)
06-13 09:12:25.259: W/webcore(656):     at android.os.Handler.handleCallback(Handler.java:605)
06-13 09:12:25.259: W/webcore(656):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 09:12:25.259: W/webcore(656):     at android.os.Looper.loop(Looper.java:137)
06-13 09:12:25.259: W/webcore(656):     at android.app.ActivityThread.main(ActivityThread.java:4424)
06-13 09:12:25.259: W/webcore(656):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 09:12:25.259: W/webcore(656):     at java.lang.reflect.Method.invoke(Method.java:511)
06-13 09:12:25.259: W/webcore(656):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-13 09:12:25.259: W/webcore(656):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-13 09:12:25.259: W/webcore(656):     at dalvik.system.NativeStart.main(Native Method)
我的XML看起来像:

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

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/navBar"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:orientation="vertical" >
    </LinearLayout>

    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webView"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="6.40" >
    </WebView>
</LinearLayout>
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

public class MobileWebView extends Activity{
private WebView myWebView;
final Context context = this;   //set the context to be itself
ProgressDialog progressDialog;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.web_view);  //set view
    //set the webview
    myWebView = (WebView) findViewById(R.id.webView);
    myWebView.getSettings().setJavaScriptEnabled(true);

    //setup and load the progress bar
    progressDialog = new ProgressDialog(context);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage("Loading. Please wait...");

    myWebView.setWebViewClient(new MyWebViewClient(){
        @Override
        public void onPageFinished(WebView view, final String url) {
            progressDialog.dismiss();


        }
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            //make sure dialog is showing
            if(! progressDialog.isShowing()){
                progressDialog.show();
            }
        }
    });

    //get the site url passed from main activity
    String urlName = this.getIntent().getExtras().getString("site");
    System.out.println(urlName);
    myWebView.loadUrl(urlName);

    SetupNavBar();
}

private void SetupNavBar(){
    //set nav bar
    LinearLayout ll = (LinearLayout)findViewById(R.id.navBar);

    NavigationBar nb = new NavigationBar(this);
    nb.setLeftBarButton("Back");
    nb.setBarTitle("Online Doctor");
    NavigationBar.NavigationBarListener nbl = new NavigationBar.NavigationBarListener() {

        @Override
        public void OnNavigationButtonClick(int which) {
            //if left button
            if(which == 0){
                finish();
            }
        }
    };

    nb.setNavigationBarListener(nbl);

    ll.addView(nb);
}


//override the override loading method for the webview client
private class MyWebViewClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if(url.startsWith("http")){
            progressDialog.show();
            view.loadUrl(url);
            return true;
        } else {
            return false;
        }
    }
}

}
在我的主课中,我称之为:

final Context context = this;   //set the context to be itself
private void setup(){
    //assign buttons
    Button login = (Button)findViewById(R.id.loginButton);
    Button register = (Button)findViewById(R.id.registerButton);

    //setup onclick for each button
    bindButtonWithVisitWebsite(login, "https://onlinedoctor.lloydspharmacy.com/login");
    bindButtonWithVisitWebsite(register,"https://onlinedoctor.lloydspharmacy.com/register");
}

private void bindButtonWithVisitWebsite(Button b, final String urlName){
    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Bundle bundle = new Bundle();
            bundle.putString("site",urlName);
            Intent intent = new Intent(context, MobileWebView.class);
            intent.putExtras(bundle);
        }
    });
}

这在ICS中对我起了作用。

我也有同样的问题。你有什么发现吗?没有。仍然期待着如何解决这个问题,尽管这个程序在任何情况下都能工作,只是不知道如何利用例外可能重复的Hi Sam:如果你看我的url,它是一个https://,所以它与这个问题有点不同,因为它不能解决我的问题。我也有同样的问题。你修好它成功了吗?你能帮忙吗?谢谢你的回答,但是在我的情况下它也不能修复这个错误:-s
WebSettings settings = webView.getSettings();
settings.setPluginState(PluginState.ON);