0

I tried a webview to display a web page, and I faced a big problem that caused my application stop unexpectedly. I tried many times but it showed the same error.

The error is "The webview app stop unexpectedly (process net.webview)..."

My Java code:

Code: import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class MyWebView extends Activity { /** Called when the activity is first created. */ WebView mWebView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.loadUrl("http://www.google.com"); } } 

My XML layout:

Code: <?xml version="1.0" encoding="utf-8"?> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 

My manifest file:

Code: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.WebView" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="7" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".WebView" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

1 Answer 1

3

The name of your activity in the manifest is wrong. It should be:

 <activity android:name=".MyWebView" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much. You are my lifesaver. I spent a day for it. Have a nice holiday.
You are welcome. If it answers your question/problem, please accept this answer by ticking the green tick sign on the left side (i think).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.