webview - Android application closed unexpectedly -


i used following code download file. runs fine, when click download button, following error comes: "application mibooks has stopped unexpectedly."

how can solve problem in code?

package mds.mibooks;  import android.app.activity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.webkit.downloadlistener; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.button;   public class mibooks extends activity {     webview mwebview;     /** called when activity first created. */     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);         final button button = (button) findviewbyid(r.id.button1);         button.setonclicklistener(new onclicklistener() {             public void onclick(view v) {                  setcontentview(r.layout.webview);                   webview mywebview = (webview) findviewbyid(r.id.webview1);                  websettings websettings = mywebview.getsettings();                  webview mywebview1 = (webview) findviewbyid(r.id.webview1);                  mywebview1.setwebviewclient(new webviewclient());                  websettings.setjavascriptenabled(true);                   /* webview webview = (webview) findviewbyid(r.id.webview1);                  webview.addjavascriptinterface(new javascriptinterface(this), "android");                 */              //   string summary = "<html><body>you scored <b>192</b> points.</body></html>";                 // mywebview1.loaddata(summary, "text/html", "utf-8");                  mywebview1.loadurl("http://www.mibooks.com/beta/");                    mywebview1.setdownloadlistener(new downloadlistener() {                         public void ondownloadstart(string url, string useragent,                                 string contentdisposition, string mimetype,                                 long contentlength) {                             intent intent = new intent(intent.action_view);                              intent.setdata(uri.parse("www.google.com"));                    intent.settype("*zip*");                              startactivity(intent);                          }                     });              }             });     } } 

android application stopped unexpectedly normal scenario in android programming when runtime error occurred. not aware of when throwing question. got solution problem is.. 1. setcontentview(r.layout.webview); , setcontentview(r.layout.main); 1 layout point null.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -