Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid application closed unexpectedly
    text
    copied!<p>I used the following code to download a file. It runs fine, but when I click the download button, the following error comes: "Application mibooks has stopped unexpectedly."</p> <p>How can I solve this problem in my code?</p> <pre><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 the activity is 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 = "&lt;html&gt;&lt;body&gt;You scored &lt;b&gt;192&lt;/b&gt; points.&lt;/body&gt;&lt;/html&gt;"; // 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); } }); } }); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload