Dmitry Dmitry - 2 months ago 17x
Java Question

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();