Aman Kumar Aggarwal
Aman Kumar Aggarwal

Reputation: 557

BootReceiver not working in all android devices

i have been trying to overcome issue of Boot_complete receiver not working in certain devices.

Like Vivo device which have iManager app with auto-start manager. Where user can toggle app from auto start on device boot.

What should i use along with below as intent-filter to restart my service after device reboot.

Earlier thought of using Battery_Change receiver but it won't work from manifest, as i has to be runtime receiver register.

Any suggestion would be really help-full.

Below is what i have used as intent-filter for my app. In most devices its working as expected. But not in all.

<intent-filter>
  <action android:name="android.intent.action.BOOT_COMPLETED" />
  <action android:name="android.intent.action.QUICKBOOT_POWERON" />
  <action android:name="android.intent.action.REBOOT" />
</intent-filter>

Upvotes: 0

Views: 639

Answers (1)

Jordy Langen
Jordy Langen

Reputation: 3591

There is one thing my team and I discovered when facing a similar issue. You can monitor the usb state like so:

<receiver
    android:name=".MyReceiver"
    android:enabled="true">
    <intent-filter>
        <action android:name="android.hardware.usb.action.USB_STATE" />
    </intent-filter>
</receiver>

And if memory serves me right, this will send a broadcast before the regular BOOT_COMPLETED action telling you there is or isn't anything USB connected.

Some manufacturers use their own version of BOOT_COMPLETED as you can read here but the USB_STATE is an alternative, based on the things you want to do. Do note you can get multiple broadcasts using this method!

Alternatively you could look into using an AccessibilityService or the JobService from the firebase sdk. More details here.

Upvotes: 1

Related Questions