Boot_Completed Not Working on Android 10 Q API Level 29

Android 10 BOOT_COMPLETED Broadcast not received to application

try to add add android:directBootAware to your <receiver, as in DOCs

BOOT_COMPLETED not working Android

This below thing worked for me

AndroidManifest.xml

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application>

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

<service android:name="NotifyingDailyService" >
</service>

BootCompletedReceiver.class

public class BootCompletedReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent arg1) {
// TODO Auto-generated method stub
Log.w("boot_broadcast_poc", "starting service...");
context.startService(new Intent(context, NotifyingDailyService.class));
}

}

Service.class

 public class NotifyingDailyService extends Service {

@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}

@Override
public int onStartCommand(Intent pIntent, int flags, int startId) {
// TODO Auto-generated method stub
Toast.makeText(this, "NotifyingDailyService", Toast.LENGTH_LONG).show();
Log.i("com.example.bootbroadcastpoc","NotifyingDailyService");

return super.onStartCommand(pIntent, flags, startId);
}
}

Flutter app BOOT_COMPLETED receiver doesn't work

For Flutter you need to add in manifest file :

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

then onCreate of MainActivity.kt file

 if (!Settings.canDrawOverlays(getApplicationContext())) {
val myIntent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
val uri: Uri = Uri.fromParts("package", getPackageName(), null)
myIntent.setData(uri)
startActivityForResult(myIntent, REQUEST_OVERLAY_PERMISSIONS)
return
}

and rest will be same for receiver.

Edit.....

For Android - 11 changes.
you need to open settings for that system overlay permission:

startActivityForResult(
Intent(
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:$packageName")
),
REQUEST_OVERDRAW_PERMISSION_CODE
)

Check this out : https://developer.android.com/about/versions/11/privacy/permissions#manage_overlay

Android: BroadcastReceiver won't listen to BOOT_COMPLETED

There might be restriction with setting up several intent-filer action. So change you defining to the next.

<!-- Don't forget about permission -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<!-- ... -->
<receiver android:name=".helpers.notification.AlarmRebootReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">

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

For all other intent filters use separate Receiver. Now you could receive events in the your method. Just print logs, to ensure the even is coming. And few devices to check it's not a device specific.

public class AlarmRebootReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context oContext, Intent intent) {
Log.d("", "Event Received");
/**
* .....
**/
}
}

Android BOOT_COMPLETED not received when application is closed

I start my app when the BOOT_COMPLETED, so I know it's working. I add Log.d it won't show. I add Toast it show. Small differents in Manifest.xml

<receiver android:name="com.example.startuptest.StartUpBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

BroadcastReceiver not receiving BOOT_COMPLETED

Turns out the receiver wasn't in the tag of the manifest. Whoops! Thanks for your help guys! The worst part about testing this is having to keep turning off and on the phone. :P



Related Topics



Leave a reply



Submit