Slasch
Slasch

Reputation: 275

How to know if the programmatically install/update of my app is successfull

I'm currently create an application that have the possibility to updated from own code thanks to a downloaded .apk from a server.

I would like to know if the update/Install of the app is successfull. Because currently the update working fine but i don't know if the installation/update is ok or not, if the installation face a problem or if the user cancel install or somethings else. So i need to have a callback "installFinish(boolean isOk)".

i search for a day but i don't find solution for my problem.

I read lot of things, particulary this :

How to find out when an installation is completed

or this :

Android - Install Application programmatically with result

but is not what i seach. This is my code for update my app

Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file.getAbsoluteFile()), "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        ((Activity) context).startActivity(intent);

EDIT

I tried this https://stackoverflow.com/questions/29175722/how-to-get-onactivityresult-called-from-action-view-intent

but it's not working for me for two reason i think:

Maybe the last reason it's the same reason why i don't receive broadcastevent such as listening for ACTION_PACKAGE_ADDED in the app who launch the update.

Maybe i can call the method when the first time the application is launch, it's like install is successfully because the app is started.

Upvotes: 0

Views: 1390

Answers (1)

rupesh jain
rupesh jain

Reputation: 3430

Heres a work around which we use: Implement a dummy provider and override onUpgrade().onUpgrade is called whenever database is upgraded.U will need maintain one to one mapping between database version and app version.

Upvotes: 1

Related Questions