Neji
Neji

Reputation: 6839

Can we detect if android app is updated from google play on introduction of a new version?

I have a app on play store and i want to provide app update through the play store.

Also, on updation of the app i want to perform some task. So, how can i perform a task on updation of my app from the play store.

I thought of maintaining current version and cross check it every time the app is fired, is there any other efficient way such as any intent fired on app updation that can be handled on the device itself.

Upvotes: 3

Views: 1041

Answers (2)

Rajkiran
Rajkiran

Reputation: 16191

You can save your current version code in shared preferences and on upgrade, cross check the new version with the previously stored one.

if (savedVersionCode < currentVersionCode) {
    .
    .
    //PERFORM CERTAIN TASKS...
    .
    .
}

You can do this in your application's onCreate() or simply in you launcher activity's onCreate() if you have only one entry point.

Upvotes: 4

WarrenFaith
WarrenFaith

Reputation: 57672

The current version idea is a solid one. Just store it in the shared preferences and read it from there. It isn't really slow so the "negative" impact on performance can be simply ignored.

Upvotes: 1

Related Questions