开发者

How to know if Android app is redeployed ?

I'm building an SDK and I have class calle开发者_JAVA百科d e.g mainClass, so in the app MainActivity I let the developers(that uses the SDK) pass data like the app key in the mainClass constructor and then they call register function that will start registration service only the first time the app was open (using preference).

The problem is when a developer changes the app key and deploys the app again (with the new app key) the preference of the app (appFirstOpen=false) stays there and registering the new app key will not go through. I thought about checking if app key changed in the constructor but it seems like an overhead. is there away to know if the app is redployed to clear the preference or is there anyother way to get pass this issue.


To answer the question in the title, no there isn't a new deployment flag. So you will have to check other factors such as app id, in your application, or the PackageInfo or ApplicationInfo from the system. If you just wanted to wipe the data of the application you can manually clear data in Settings -> Applications, or just wipe the Preference data every time with SharedPreferences.Editor.clear().

It appears that you're having an issue when the same application run against a new app id. This would suggest to me that working with the overhead of checking the app id would be worth doing. I would suggest have one preference file per app id it will be able to handle appFirstOpen conditions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜