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();
onCreate
callback. Still, this requires the user to start the app at least once. But where do you put this code if you do not have an activity or if you cannot rely on the user to start the activity? –
Angadresma 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.
© 2022 - 2024 — McMap. All rights reserved.