但它会产生如下所示的错误
09-25 20:42:56.732: ERROR/LocationManagerService(64): requestUpdates got exception:
09-25 20:42:56.732: ERROR/LocationManagerService(64): java.lang.IllegalArgumentException: provider=network
09-25 20:42:56.732: ERROR/LocationManagerService(64): at com.android.server.LocationManagerService.requestLocationUpdatesLocked(LocationManagerService.java:861)
09-25 20:42:56.732: ERROR/LocationManagerService(64): at com.android.server.LocationManagerService.requestLocationUpdates(LocationManagerService.java:831)
09-25 20:42:56.732: ERROR/LocationManagerService(64): at android.location.ILocationManager$Stub.onTransact(ILocationManager.java:79)
09-25 20:42:56.732: ERROR/LocationManagerService(64): at android.os.Binder.execTransact(Binder.java:287)
09-25 20:42:56.732: ERROR/LocationManagerService(64): at dalvik.system.NativeStart.run(Native Method)
package com.webview;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebApplicationActivity extends Activity {
WebView webView1,webView2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView1 = (WebView) findViewById(R.id.webView1);
webView1.loadUrl("http://google.com");
// webView2 = (WebView) findViewById(R.id.webView2);
// webView2.loadData("<html><head></head><body>Hello</body></html>", "text/html", null);
}
}
<?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="wrap_content">
<android.webkit.WebView android:layout_width="fill_parent"
android:id="@+id/webView1" android:layout_height="300dp"
android:layout_weight="1"></android.webkit.WebView>
<!-- <android.webkit.WebView android:id="@+id/webView2"
android:layout_width="fill_parent" android:layout_height="300dp"
android:layout_weight="1">
</android.webkit.WebView> -->
</LinearLayout>
答案 0 :(得分:0)
您的错误来自位置管理器模块尝试从蜂窝网络获取用户当前位置,而不是来自您发布的代码。
答案 1 :(得分:-1)
检查这段代码
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.setSaveFormData(false);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
在xml文件中。应该有webview id。
android:id="@+id/webview"
还必须将此权限放在AndroidManifest.xml文件中。
<uses-permission android:name="android.permission.INTERNET" />
在HelloAndroid Activity中,添加此嵌套类:
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
然后在onCreate(Bundle)方法的末尾,将HelloWebViewClient的实例设置为WebViewClient:
mWebView.setWebViewClient(new HelloWebViewClient());