android 開機自啟動的幾種方法,監聽不到RECEIVE_BOOT_COMPLETED的處理辦法


第一種:  監控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>



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM