Android的,如何确定是否重新启动发生? [英] Android, how to determine if a reboot occurred?
问题描述
如何编程方式确定时,Android设备已经重新启动(无论是单独,或用户发起的)?
How would I programmatically determine when an android device has rebooted (whether on its own, or user initiated) ?
推荐答案
建立一个BroadcastReceiver并注册在你的清单,甚至响应android.intent.action.BOOT_COMPLETED系统。当手机开始了code在你的BroadcastReceiver的的onReceive方法运行。请确保它要么产生一个单独的线程或时间不超过10秒,该操作系统将在10秒后摧毁你的BroadcastReceiver线程。
Set up a BroadcastReceiver and register it in your manifest to respond to the android.intent.action.BOOT_COMPLETED system even. When the phone starts up the code in your broadcastreceiver's onReceive method will run. Make sure it either spawns a separate thread or takes less than 10 seconds, the OS will destroy your broadcastreceiver thread after 10 seconds.
这篇关于Android的,如何确定是否重新启动发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!