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
What's the Equivalent of Java's Thread.Sleep() in JavaScript
Jsoup Get Dynamically Generated HTML
Sending Variable from One Jsp to Another Jsp
Spark: How to Map Python with Scala or Java User Defined Functions
Call and Receive Output from Python Script in Java
Finding Signed Angle Between Vectors
Choosing Java VS Python on Google App Engine
How Does the Fetchmode Work in Spring Data JPA
Sending Message to Specific User on Spring Websocket
Calculate Distance in Meters When You Know Longitude and Latitude in Java
How to Make Spring Inject Value into a Static Field
Change Name of Import in Java, or Import Two Classes with the Same Name
Stack Overflows from Deep Recursion in Java
How to Call a Method Stored in a Hashmap? (Java)
What Would Be the Fastest Method to Test for Primality in Java
Why Is the Range of Bytes -128 to 127 in Java