Any way to know if Device booted from a fastboot?

2019-04-09 06:13发布

问题:

Ever since HTC started using Fastboot settings, apps depending on

android.intent.action.BOOT_COMPLETED

struggle to boot along with the device boot on HTC devices. I have a similar application which depends on the above intent action. But since HTC does its power off and power on differently by using fastboot(other term used - Hibernation) my App never get to work normally. I tried using ACTION_USER_PRESENT and ACTION_SCREEN_ON, but it seemed to be more of hack than a fix for my problem. Do any of you came across same kind of problem and found a better way to deal with it? Please help. SKU

回答1:

In case anyone is programming with an HTC Droid DNA as their target, I discovered that its "fast boot" doesn't send "android.intent.action.QUICKBOOT_POWERON", but rather sends "com.htc.intent.action.QUICKBOOT_POWERON".

I hope this helps someone somewhere as it took me hours to figure this out.



回答2:

I found the intent action that HTC uses during Fastboot Power On and Power Off. I thought of sharing it here as it may be useful for someone else who is facing same problem as me.

Here is the intent action you need to register in AndroidManifest.xml under your Receiver.

<receiver android:name="com.my.app.MyReceiver">
     <intent-filter>
         <action android:name="android.intent.action.BOOT_COMPLETED"/>
         <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
     </intent-filter>
</receiver>

Hope it was helpful