Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event when application gets installed (Android)

Tags:

java

android

Is there any event triggered when the application is finished installed in the phone.I have seen some post but no luck ,there were similar question asked but no answer was found. Any help would be appreciated. Thanks in advance.

like image 491
Sam97305421562 Avatar asked Oct 11 '10 08:10

Sam97305421562


2 Answers

No you can't, the user has to explicitly start your application.

You can always check for the first time your application is launched.

like image 139
Colin Hebert Avatar answered Sep 25 '22 22:09

Colin Hebert


The easiest way to check if your application has to do the installation tasks or not is to check your SharedPreferences when your main Activity is created. As your app has not run before, you're preferences will be empty:

SharedPreferences prefs = getSharedPreferences(SHARED_PREF_NAME, MODE_PRIVATE);
if (!prefs.contains(FIRST_RUN_KEY)) {
   prefs.edit().putBoolean(FIRST_RUN_KEY,false).commit();
   // TODO Do stuff that should be done at the first run
}
like image 28
Andras Balázs Lajtha Avatar answered Sep 22 '22 22:09

Andras Balázs Lajtha