我有一个非常简单的应用程序,我无法让 WebView 显示 google.com(这就是我用来测试的内容
这是我的 list :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bantol.mpp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MPPActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".SMSReceiver" >
<intent-filter android:priority="100" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
这是我在 MPPActivity
中使用的代码:
@Override
public void onResume()
{
super.onResume();
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
return true;
}
});
mWebView.loadUrl("www.google.com");
}
WebView 显示网页不可用,但 LogCat 上没有错误或消息
我错过了什么?
我在我的设备上测试这个,而不是模拟器。
最佳答案
www.google.com
不是 url,但 http://www.google.com
是。修复您的 loadUrl() 调用以保存正确的 url,它应该可以工作(如果您有有效的连接等)。
关于android - WebView 不适用于 INTERNET 权限集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10001264/