Questions tagged [android-broadcastreceiver]

BroadcastReceiver is an Android component that responds to system-wide broadcast announcements.

BroadcastReceiver is an Android component that responds to system-wide broadcast announcements.

Many broadcasts originate from the system – for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured.

Applications can also initiate broadcasts – for example, to let other applications know that some data has been downloaded to the device and is available for them to use.

Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just a "gateway" to other components and is intended to do a very minimal amount of work. For instance, it might initiate a service to perform some work based on the event.

For more information visit the Android BroadcastReceiver reference or the documentation for the receiver element used in the Android manifest file.

859 questions
14
votes
1 answer

Broadcasts are delayed

We use broadcasts to communicate state changes between a remote services and our UI. Doing this, we discovered a very strange behaviour: Sometimes (I can not find any clues why) these broadcasts are delayed around 8s. How we send them (pretty…
Mike Kasperlik
  • 311
  • 2
  • 12
14
votes
3 answers

Crash while self updating APK (component class does not exist)

I am working on a system application which updates itslef by downloading an apk and installing it by using PackageManager's installPackage() method. I am getting the following exception: Fatal Exception: java.lang.IllegalArgumentException: Component…
13
votes
1 answer

Local broadcast from Service not received by Activity

I have an Activity in which I am registering a BroadcastReceiver locally as follows: public class SomeActivity extends Activity{ public static final String PERFORM_SOME_ACTION = "PERFORM_SOME_ACTION"; @Override protected void…
13
votes
3 answers

Alarm Manager does not work in background on Android 6.0

This is my Activity code, Long time = new GregorianCalendar().getTimeInMillis()+20000;//Setting alarm after 20 sec Intent intentAlarm = new…
12
votes
1 answer

Unable to wake up app from background on Xiaomi devices till "Autostart" is enabled manually

On Xiaomi's MI devices, there is a feature of turning off/on "Autostart" in their security app. (In Security App->Permissions->AutoStart) This means none of the broadcast receivers receive anything while the app is not running. So BOOT_COMPLETED,…
11
votes
5 answers

Install referrer not working in some redmi devices

I need to track install referrals for my android app. It's working fine in most of the devices. But in Redmi device, the broadcast is not getting triggered. I tested it with Redmi Note 4 I have tested it both from via ADB as well as play store. Both…
11
votes
2 answers

Overlay Window Service In Android

I have to implement an Overlay Window like True Caller App has.But the problem I am getting is, During any Incoming or Outgoing call my service automatically getting close or destroyed. Service class public class OverlayService extends Service…
10
votes
2 answers

Service has leaked IntentReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?

I'm using a foreground Android Service to request a resource with Retrofit, via REST API, as a timer every 60 seconds. Such service is also running in a different process than the app, this is necessary so that Android doesn't kill it when falls…
jbarros
  • 628
  • 10
  • 28
10
votes
1 answer

Boot BroadcastReceiver does not work on Xiaomi devices

I have a following BroadcastReceiver which should run after boot completion. I have tested it on my Xiaomi device (Redmi 1s), it's not running, while on other devices like Samsung it's running as expected. public class DeviceBootReceiver extends…
9
votes
1 answer

Intent extras are empty in onReceive of BroadcastReceiver

I want to get some arguments from Intent in onReceive() method of BroadcastReceiver class. But there's only int ALARM_COUNT = 1, although I put two args: my Parcelable Alarm object and test int (for the case when there is some problem with alarm…
9
votes
2 answers

Change color of an random item in ListView when connectivity change is detected

I have a broadcast receiver which receives connectivity change broadcast.So it is triggered whenever connectivity change is detected.I have a list view with 10 items.Each item has a EditText which contains the position of that particular item from 0…
9
votes
1 answer

Lifetime of BroadcastReceiver with regard to Android O changes

If I declare a BroadcastReceiver via the mainfest file for a system broadcast (let's say for example ACTION_POWER_DISCONNECTED) the the system will call it every time the specific broadcast is send so the lifetime of the BroadcastReceiver is…
Cilenco
  • 6,951
  • 17
  • 72
  • 152
9
votes
1 answer

Unit Testing a BroadcastReceiver

I've been trying to figure out how to unit test my BroadcastReceiver and I have looked at StackOverflow and other websites but I can't find the solution to my problem. In my mainActivity I have the following two functions: private void…
8
votes
3 answers

Fatal Exception: java.lang.IllegalArgumentException: Receiver not registered: android.hardware.camera2.CameraManager

I am developing a flashlight app that switch on/off the system tourch. I have a crash that shown on Android M (v6.0) on Crashlytics Here is the Issue details and stacktrace: Fatal Exception: java.lang.IllegalArgumentException: Receiver not…
8
votes
3 answers

Broadcast charger disconnected in Android O

Now that the final API for Android O is released and none of the following broadcasts is whitelisted I have the following problem: In my application (targets API 25) I currently have a BroadcastReceiver which listens for system events of…
1
2
3
57 58