0

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>
Aman Kumar Aggarwal
  • 557
  • 1
  • 5
  • 16

1 Answers1

1

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.

Community
  • 1
  • 1
Jordy Langen
  • 3,591
  • 4
  • 23
  • 32
  • Thank you for suggesting USB_State giving it a try. Well basically below is what i can see in logcat that iManager is blocking up app from getting boot_complete action. 05-01 07:39:51.110 2155-2183/? W/BroadcastQueue: Cancel launching app com.testing.app/10178 for broadcast Intent { act=android.intent.action.BOOT_COMPLETED flg=0x8000010 (has extras) }: process is forbid to start up – Aman Kumar Aggarwal May 01 '17 at 18:10
  • Hi, @Jordy I have tried USB_STATE but upon reboot unable to intercept same event in receiver. – Aman Kumar Aggarwal May 01 '17 at 18:19
  • Hi @Jordy Getting below issue 05-01 16:35:03.394 2219-4544/? W/BroadcastQueue: Cancel launching app com.testing.app/10180 for broadcast Intent { act=android.hardware.usb.action.USB_STATE flg=0x20000010 (has extras) }: process is forbid to start up – Aman Kumar Aggarwal May 01 '17 at 18:36
  • Hi @jordylangen Getting below issue `05-01 16:35:03.394 2219-4544/? W/BroadcastQueue: Cancel launching app com.testing.app/10180 for broadcast Intent { act=android.hardware.usb.action.USB_STATE flg=0x20000010 (has extras) }: process is forbid to start up` – Aman Kumar Aggarwal May 01 '17 at 18:43
  • Does iManager block every kind of intent receiving? You could try this by checking if the user unlocks the screen (`android.intent.action.USER_PRESENT`) – Jordy Langen May 01 '17 at 18:48
  • Updated my answer, have a look at http://stackoverflow.com/questions/41524459/broadcast-receiver-not-working-after-device-reboot-in-android?rq=1 – Jordy Langen May 01 '17 at 19:07