在WebView中执行操作时出错

时间:2014-01-24 07:51:17

标签: android webview browser webviewclient webchromeclient

我可以在WebView中加载网址。但是,如果我执行某些操作(例如点击事件),我会在LogCat中收到以下错误:

Unable to get value of the property 't': object is null or undefinedundefined

但是如果我从模拟器的浏览器中执行某些事件,它就可以正常工作。

以下是基于post

的代码
public class MainActivity extends Activity {

WebView mWebview = null;
String URL = "********";  // Masked intentionally.

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    //setContentView(R.layout.activity_main); //Not required as per comment given by Raghunandan.

    mWebview  = new WebView(this);

    mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript

    final Activity activity = this;

    mWebview.setWebChromeClient(new WebChromeClient());

    mWebview.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
        }
    });

    mWebview .loadUrl(URL);
    setContentView(mWebview );

    }
}

注意:网页是使用AngularJS开发的。

我在Manifiest.xml中添加了以下属性:

<uses-permission android:name="android.permission.INTERNET" /> 

0 个答案:

没有答案