Android register to remote server on first application uses
I am writing a android application where I want to register my application to remoter server when application is first launched on installation. Application will register to remoter server itself without taking any user input. How Can I track whether this is a first开发者_运维百科 application launch after installation ?
By setting a shared preference:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor edit = prefs.edit();
edit.setBoolean("launched", true);
edit.commit();
You can check for it on each launch with:
boolean launched = prefs.getBoolean("launched", false);
精彩评论