My appllication implements an auto upgrade capability as the app will not be release to market. The apk file is hosted on a webserver. I have implemented part one of the following link
Use AsyncTask and show the download progress in a dialog
Now when I run the application the following things occur.
If a new version is available then the application prompts the user if they want to upgrade.
If the user selects yes then the application downloads the file from the server.
- Once completed the app then prompts the user if they want to replace the app
- If the user hits ok then the application starts to install but fails with the following screen
There is no log file information provided as to why this occurs. Please could someone help me understand what could be causing this issue. This is default android code to produce the fianl 2 screens not my code.
This occurs after the following code has been run on the asyncronous task:
protected void onPostExecute(String result) {
super.onPostExecute(result);
// dismiss the progress dialog
mProgressDialog.dismiss();
// get the file
String path = getFilesDir().getAbsolutePath()+ File.separator + getString(R.string.apk_file);
File file = new File(path);
// if it exists
if(file.exists()) {
// create and start the intent with the new file
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
} else {
// display error message
Toast.makeText(context, "File was not downloaded", Toast.LENGTH_LONG).show();
}
}
If i uninstall the app and use the browser to go the file location the app is downloaded automatically and then I can install it succesfully from the downloads folder.
Could this be a problem that the app is trying to Install its self while the app is currently running? The file is downloaded to the internal memory during the upgrade process and not the SD card location as I cannot guarentee that the users device will have an SD card present.