I have following code:
public class reader extends Activity {
WebView mWebView;
String mFilename;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webView1);
setContentView(R.layout.webview);
mWebView.loadUrl("http://www.google.com");
}
}
When I run this, the emulator shows “Sorry:.. mireader Stopped unexpectedly” error.. Why ?
Why do you have
setContentView(R.layout.webview);? You already callsetContentViewtwo lines before.And do you have the
android.permission.INTERNETpermission in your AndroidManifest.xml?Also, you should attach the logcat output as that’ll probably give you a callstack pointing you in the general direction of the problem.