Reputation: 1
So I have created this simple app that will view my webpage on a "webview" widget. It works with no interruptions and its is smooth when installing, but the thing is that it doesn't show the web page, instead it says "Web page not available".
Everything is good and no Errors in Eclipse, that is the code:
private WebView myWebView;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.webView);
myWebView.loadUrl("http://www.aramco-values.webs.com");
the SupportLint is initialized by Eclipse under the OnCreate method, I don't know if it is the problem or not because it must be there or mtWebView won't work.
ManiFest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aramcoapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="12" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.aramcoapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Eclipse warned me about the sdk that I have set at the beginning of the app creation
minimum = 11 target = 12
Upvotes: 0
Views: 1419
Reputation: 4856
In order to access the Internet and load web pages in a WebView, you must add the INTERNET
permissions to your Android Manifest file:
<uses-permission android:name="android.permission.INTERNET" />
Source : http://developer.android.com/reference/android/webkit/WebView.html
[EDIT]
WebView webView = (WebView) findViewById(R.id.webview);
webView.loadUrl("http://www.aramco-values.webs.com");
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.i("WEB_VIEW_TEST", "error code:" + errorCode);
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
Upvotes: 2
Reputation: 2979
you need to declare internet acess permission in manifest file
<uses-permission android:name="android.permission.INTERNET" />
try now
Upvotes: -1