开发者

Is there on install event in android?

Is there some event/receiver开发者_运维问答 or something for handling first execution after installation or directly after installation? Or Do I need it emulate with preferences?


There is the ACTION_PACKAGE_ADDED Broadcast Intent, but the application being installed doesn't receive this.

So checking if a preference is set is probably the easiest solution.

SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
boolean firstRun = p.getBoolean(PREFERENCE_FIRST_RUN, true);
p.edit().putBoolean(PREFERENCE_FIRST_RUN, false).commit();


See Get referrer after installing app from Android Market - you can put whatever you want in there. I believe this is how Plan B works - the app that can send back your phone's location after it's stolen, that you install from the website after it's been stolen.


I don't think there is such a thing, and I don't think this would be a good idea : usually you have to handle not only installations but some updates (say : a new version with features) or the proper initialization of some resources.

For the resources, the best way is to check them directly.

For the version, I use the database, it's so easy.


The SQLiteOpenHelper's OnUpgrade method is called when the database version changed. I suppose this could be used to do other things than just handling the new schema.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜