Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4580600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:48:22+00:00 2026-05-21T20:48:22+00:00

I used the following code to download a file. It runs fine, but when

  • 0

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.”

How can I solve this problem in my 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 = "<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);

                        }
                    });

            }    
        });
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:48:23+00:00Added an answer on May 21, 2026 at 8:48 pm

    Android application stopped unexpectedly it is normal scenario in android programming when any runtime error is occurred. i was not aware of this when i was throwing this question. I got solution for this problem that is..
    1. setContentView(R.layout.webview); and setContentView(R.layout.main); one layout is point to null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the following code to download/save an image and open it later, but
I have used following code to create a simple PDF file. It executes fine
Following java code is being used to download a requested log file throgh a
i have used a code to download file it works well in IE7,, but
I used following code, but it displays only 2 digit of ISO country name.
I am trying to used following code but I am not getting good performance
I've used following code for parsing XML file in c++. http://www.codeproject.com/Articles/176236/Parsing-an-XML-file-in-a-C-C-program . Now I
I'm trying to download a file from an opa database. I've used the following
I used following code for downloading XML file from ftp to android phone memory
I have used following code for download some files from our internet. public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.