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
5
votes
1 answer

Broadcast receiver doesn't work inside foreground service in Android 8

I'm trying to create an app that allows users to silence the device during set time intervals or manually. I would also like users to be able to enter more complex rules such as mute the phone only when connected to a certain WiFi network, Bluetooth…
5
votes
1 answer

Manifest-declared BroadcastReceiver not picking up explicit broadcast when app is not running

I am trying to get two apps to communicate via broadcasts. The first app sends a broadcast using code like the following: Intent outIntent = new Intent("org.example.WHATEVER"); PackageManager pm = this.getPackageManager(); List
user149408
  • 5,385
  • 4
  • 33
  • 69
5
votes
1 answer

Listen to HDMI plugged and unplugged events on Android TV

I need to receive the HDMI state events for my Android TV app. I found this code in several places: public class HdmiListener extends BroadcastReceiver { private static String HDMIINTENT = "android.intent.action.HDMI_PLUGGED"; @Override …
5
votes
2 answers

Broadcast-receiver which always receives broadcast (even in background) for API Level +26

I'm posing this as Q&A style because I found this idea working. And it's a fix to the hard problem to crack for beginners with Android. Google has deprecated registering Broadcast Receiver into manifest like this below from API Level 26+ ( Except…
5
votes
1 answer

How to get phone call log history of organisation work profile in my application (Published as Private app)

Here I am trying to get last call log history in my application after call ended with released apk (Published on play store as public app). Now I have released my app as private app for one organization I am not able to get call log history in my…
5
votes
1 answer

How to detect process foreground for Android O

On our application there's a service that is normally started during Application.OnCreate (directly calling context.startService) and also later on via AlarmManager (refactor is in progress to migrate some of its work to JobScheduler). Our…
Budius
  • 39,391
  • 16
  • 102
  • 144
5
votes
1 answer

I always see "E ActivityManager: Sending non-protected broadcast from system" in android 7. What does this mean?

I am trying to send an intent from a non system app using the following function. public static void sendIntent() { if (null != _context) { Intent intent = new Intent("com.test.testApp.testIntent"); …
5
votes
0 answers

How to differentiate between USB and SD mount?

I have an Android 6.0 phone with internal memory, removable SD card and USB OTG (pen-drive with micro USB jack) inserted in the phone. Removable SD card and USB OTG was ejected in Android equipment: "Settings" -> "Storage & USB". I can mount…
5
votes
1 answer

How to use MediaSession.setMediaButtonReceiver(PendingIntent) to resume playback

I'm trying to be able to start music playback from my app when the headset buttons are clicked while my app is stopped. I can use MediaSession.Callback onMediaButtonEvent() or the now deprecated registerMediaButtonEventReceiver() to listen for media…
5
votes
2 answers

Alarm Manager not working at specific given time interval

Hi I am using alarm Manager for specific time interval for 3 minutes and I started monitoring. It worked for sometimes and suddenly I noticed there is irregular time interval which is not correct! You can see in attached log where at "20-Jul-2016…
5
votes
1 answer

Register Broadcast Receiver from another Broadcast Receiver in android

Currently I have Broadcast Receiver for listening call states events. I have registered Broadcast Receiver in AndroidManifest.xml as shown below.
Rajesh Jadav
  • 12,801
  • 5
  • 53
  • 78
5
votes
3 answers

Android BroadcastReceiver onReceive() called twice on android 5.1.1 even after one register

I Could not figure out what is wrong with below code. I also checked about registering receiver twice. But that's also not the case. or may be I am missing something. Could any please help. I really need it. :( import android.app.Service; import…
Bharat
  • 750
  • 1
  • 9
  • 20
5
votes
1 answer

SUPPLICANT_CONNECTION_CHANGE_ACTION never received

I am looking to be notified when the device switches networks but for some oddball reason, in spite of the documentation and various examples on SO, this particular action never gets sent to my receiver. Here's my code RECEIVER: BroadcastReceiver…
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
5
votes
2 answers

BroadcastReCeiver internal implementation

I am trying to understand how broadcast receiver works internally. What happens internally when I call registerReceiver() method? Does it create a service internally ? What happens internally when I call sendBroadcast? If I have to implement my own…
5
votes
3 answers

How to get Outgoing call number with date and time?

I am getting Incoming call Details(Number,Name,Date). But How to get outgoing call details. I have written a code for outgoing calls details but it throws NullPointerException. Below is my MyCallReceiver.java file and manifest file public void…
Pratik Sule
  • 163
  • 4
  • 18