How to know if is the app first execution after device reboot
I want to know if there are any method to know if is the first exuctio开发者_如何学运维n of an app after reboot, or the app is alredy executed by the user (the app have one activity and to recivers).
I'm thinking in methods like write and rewrite a token file every minute, and each time the app starts, check the lastmodified property to know the state, but i think that must be smart ways to do it.
Any idea?
Thanks in advance,
You can register BroadcastReceiver to listen for ACTION REBOOT intent and when this happens to store the reboot time in SharedPreferences. Next time you start your application check if there are new reboots between two starts of your application.
精彩评论