第一種: 監控RECEIVE_BOOT_COMPLETED,即開機啟動事件
另外一種: 監控sd卡mount事件 開機總會掃描sd卡吧? 監控sd卡事件也有類似開機啟動效果。特別app安裝在sd卡的情況下有些os是抓取不到RECEIVE_BOOT_COMPLETED
第三種: android:installLocation="internalOnly", 限制app的安裝位置,使其能抓取到RECEIVE_BOOT_COMPLETED
第四種: 監聽電話或者短信事件。手機總得打電話收發短信吧? 萬一實在不行。退而求其次。這樣的方式還是可行的。
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:name="com.example.receiver.SystemEventReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="RestartSerivcesForSystemEventReceiver" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<action android:name="android.intent.action.MEDIA_UNMOUNTED" />
<action android:name="android.intent.action.MEDIA_EJECT" />
<data android:scheme="file" >
</data>
</intent-filter>
</receiver>
