How to update the APK of my application, when the user requests it?

Explanation:

I have an application that is constantly made quite changes, and every time I do, I generate a new version with the same private Key(Keystore), that is, when I send the new *.APK install on the device no configuration is lost and the application is simply updated. So far so good.

Question:

However, I don't want the user to have to download a new one *.APK in my site and subsequently install every time it is necessary to update it, I would like to make a "Update" button and when clicked, transfer the new *.APK with a progress bar monitoring the end of the download to the device, and automatically install it, with another progress bar monitoring the end of the installation(if it is not possible it can be an "ajax" that would be that progress that is spinning without prediction), How Should I do this?

Detail important:

I do not want to use Google Play to do this for me because some users who have my application can not, at some point, use, for example, version 1.21, and only 1.20, since other users can already upgrade to version 1.21.

And also, I would not want the update to be performed automatically, as I need the user to finish all the services in their application before they can update. And it should only update when it is prompted to click the button.

Author: Paulo Roberto Rosa, 2014-03-12

2 answers

You may even have a button in the app that downloads an apk, but the user will have to access that apk and request the update manually. Only the operating system can update an application. No app has this level of permission, as it would be a serious security flaw, especially if your APK requires new permissions.

The Play Store offers all the necessary features to make new versions available to users, being smart enough in order not to conflict with any running services.

If you think your application will behave unexpectedly during an update, you need to reproduce this error and post the code and exception here.

I recommend not trying to reinvent the wheel and use the Play Store.

 2
Author: Androiderson, 2014-03-12 15:16:30

You can download the apk and have it installed normally:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivityForResult(intent, RC_INSTALL);

Or you can create an app that carries a new one with you .apk and installs with the same code above, should only be tested in the case of update (since installation works).

 1
Author: , 2014-04-14 14:00:45