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 6838013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:32:45+00:00 2026-05-26T23:32:45+00:00

I have placed a conditional checking in the oncreate of my application for checking

  • 0

I have placed a conditional checking in the oncreate of my application for checking the version update.If New version of my application available I will call the onDestroy.

public void onCreate(Bundle savedInstanceState) {
    if(“true”.equal(CheckVersion))
    {
        alertbox.setMessage("Do you want to update Aplication with Latest version?");
        alertbox.setPositiveButton("Yes",
                new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {

                try {

                    onDestroy();
                } catch (Exception exception) {

                    exception.toString();
                }                       

            }
        });
        alertbox.setNegativeButton("No",
                new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                LaunchManifest();
            }
        });
        alertbox.show();
    }
}

/*
 * In the onDestroy method I have Placed the code for downloading the New
 * apk file and installation of the apk file methods as given below
 */
@Override
public void onDestroy() {
    DownloadOnSDcard();
    InstallApplication();
}

public void DownloadOnSDcard() {
    try {

        urlpath = "http://192.168.1.158/VisionEPODWebService/VisionEPOD.apk";
        String ApkName = "VisionEPOD.apk";

        URL url = new URL(urlpath.toString());
        // Your given URL.
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setRequestMethod("GET");
        c.setDoOutput(true);
        c.connect();
        // Connection Complete here.!
        // Toast.makeText(getApplicationContext(),
        // "HttpURLConnection complete.", Toast.LENGTH_SHORT).show();
        String PATH = Environment.getExternalStorageDirectory() + "/download/";
        File file = new File(PATH); // PATH = /mnt/sdcard/download/
        if (!file.exists()) {
            file.mkdirs();
        }
        File outputFile = new File(file, ApkName.toString());
        FileOutputStream fos = new FileOutputStream(outputFile);
        // Toast.makeText(getApplicationContext(), "SD Card Path: " +
        // outputFile.toString(), Toast.LENGTH_SHORT).show();
        InputStream is = c.getInputStream();
        // Get from Server and Catch In Input Stream Object.
        byte[] buffer = new byte[1024];
        int len1 = 0;
        while ((len1 = is.read(buffer)) != -1) {
            fos.write(buffer, 0, len1); // Write In FileOutputStream.
        }
        fos.close();
        is.close();
        // till here, it works fine - .apk is download to my sdcard in
        // download file.
        // So plz Check in DDMS tab and Select your Emualtor.
        // Toast.makeText(getApplicationContext(),
        // "Download Complete on SD Card.!", Toast.LENGTH_SHORT).show();
        // download the APK to sdcard then fire the Intent.
    } catch (IOException e) {
        Toast.makeText(getApplicationContext(), "Error! " + e.toString(), Toast.LENGTH_LONG)
        .show();
    }
}

public void InstallApplication() {
    String ApkName = "VisionEPOD.apk";
    String PackageName = "com.Vision.EPOD";
    Uri packageURI = Uri.parse(PackageName.toString());
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, packageURI);
    intent.setDataAndType(
            Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/"
                    + ApkName.toString())), "application/vnd.android.package-archive");

    startActivity(intent);
}

The problem is that when my method for installation is got executed it shows an alert box

Replace application
The application you are installing will replace another application. All previous user data will be saved.
And have OK and Cancel button

When I clicked ok button it show another button for installation of the application

But when I clicked the Installation button the application shows a progress bar showing installing

Then after that I will got a message application not installed with done button.

ie My new updates not got installed.

Is it the right way I have implemented the version update procedure. Will any one review please.Sorry for the lengthy code.

  • 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-26T23:32:45+00:00Added an answer on May 26, 2026 at 11:32 pm

    This is most likely due to the fact that you first install the application on your device from Eclipse. Doing this will sign your app with one certificate.

    Then you have your .apk-file placed at some location – to make this .apk-file you had to sign it with a certificate.

    The certificate that Eclipse signed your app with is not the same as the one you signed your .apk-file with – meaning when you download the .apk-file and try to install it, there will be a certificate mismatch and it won’t install.

    What you could do is:

    1. Install the app via the .apk-file on your device
    2. Create a newer version of the .apk-file and place it on the web.
    3. Run the app on the device and the update should succeed.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few models that need to have custom find conditions placed on
I have placed an image on the master page. I see the image at
I have a Template Column under which I have Placed a Dropdownlist. Now I
I have a horizontal list on which I have placed borders on the li
I'm using the Excel interop in C# ( ApplicationClass ) and have placed the
How to access App_Data folder in WCF service? I have placed a xslt file
I am using Ajax tab container control with 3 tabs. I have placed a
I have an Expander placed on a window with a blue background and I
I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed
I have an animated gif placed on the button. It's animating ok (most of

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.