Questions tagged [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.

8368 questions
2
votes
2 answers

Broadcast Receiver for Sent SMS

Is there a Broadcast Receiver in android to listen to the SMS sent event? In my application I want to count the number of SMS sent every predefined time interval. If its not possible to listen to sent sms, can anyone share code to count SMS and for…
Khurram Majeed
  • 2,291
  • 8
  • 37
  • 59
2
votes
2 answers

Broadcast receiver registered from code

I register receiver from the onCreate from my activity like this IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); BroadcastReceiver mReceiver = new…
Lukap
  • 31,523
  • 64
  • 157
  • 244
2
votes
0 answers

What have changes about broadcast receiver on Android 11?

I'm using an Android foreground Service to download files and I'm showing the progress of the download to the user in a Notification. I also have a progress bar in a fragment in the app. I'm using a broadcast Receiver to communicate the progress of…
loic .B
  • 281
  • 2
  • 11
2
votes
0 answers

Getting current location in a Broadcast receiver- Android

My goal is to get a single pair of coordinates upon a received broadcast. What I've done so far is the following: @Override public void onReceive(Context context, Intent intent) { // API 31 and above if(Build.VERSION.SDK_INT >=…
Alessandro
  • 107
  • 1
  • 8
2
votes
0 answers

ActivityTransitions API not calling BroadcastReceiver on Samsung Deivce

I implemented the Activity Transitions API with a PendingIntent and a BroadcastReceiver as seen below. The code works perfectly fine on a Pixel 3a. However, on a Samsung A32 and Samsung S22 Pro, the Broadcast receiver is never reached, eventhough…
2
votes
1 answer

The order when BroadcastReceiver starts a Service

I find that when a BroadcastReceiver starts a Service in onReceive() method, the return of onReceive() will happen before the onCreate() of the Service being invoked. Why does this happen in this order? The example code is below:…
Harry
  • 31
  • 3
2
votes
2 answers

android13 RECEIVER_EXPORTED's explanation is correct?

Choose whether the broadcast receiver should be exported and visible to other apps on the device. If this receiver is listening for broadcasts sent from the system or from other apps—even other apps that you own—use the RECEIVER_EXPORTED flag. If…
skytree
  • 23
  • 1
  • 4
2
votes
1 answer

close() was never explicitly called on database

I need to store sms in a sqlite database, when one is received. I'm using these classes: DBHelper.java public class DBHelper extends SQLiteOpenHelper { private static final String DB_NAME = "my_db"; private static final int DB_VERSION = 1; …
supergiox
  • 1,586
  • 7
  • 19
  • 27
2
votes
1 answer

Android 12 - Activity Recognition With broadcast receiver in background not working

I am trying to get user activity states by ActivityRecognition API and it works in foreground and for few hours in background too (When user exit the app) but after more than 4/5 hours it stop sending user activity states by ActivityRecognition…
androidXP
  • 1,692
  • 3
  • 27
  • 58
2
votes
0 answers

Detect theme change in background in Android

How can I detect when theme(dark or light) is changed in Android? I need to do this in background(when app is not running). I tried BroadcastReceiver with action Intent.ACTION_CONFIGURATION_CHANGED but it does not work in background. Maybe I can do…
Renattele Renattele
  • 1,626
  • 2
  • 15
  • 32
2
votes
1 answer

Listening and reciveing specific SMS message?

Ok i Have this broadcast reciver for Listening incoming SMS public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //---get the SMS message passed in--- …
Goran
  • 1,239
  • 4
  • 23
  • 36
2
votes
1 answer

USB Request Permission action Broadcast not received

I'm using the following code to get access to a USB Device on Android. private final String ACTION_USB_PERMISSION = "com.myapp.USB_PERMISSION"; private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { public void…
Nimila Hiranya
  • 4,842
  • 10
  • 35
  • 52
2
votes
1 answer

.Net Maui BroadcastReceiver does not receive anything

I implemented an BroadcastReceiver for Android-Platform to detect whenether the Devices Battery is being Charged or not. Unfortunately, it doesn't seem to work on my Device which has Android 10 installed (Android 10 is my minimum requirement for the…
2
votes
1 answer

Android Bluetooth Broadcast Receiver Issues with ACL_CONNECTED and AC_DISCONNECTED in android 12

I am writing an broadcast receiver that detects whether or not a bluetooth device is connected. here is my bluetooth broadcast receiver : val filter = IntentFilter().apply { addAction(BluetoothDevice.ACTION_ACL_CONNECTED) …
2
votes
1 answer

how to handle SMS SENT event?

I'm writing an app that sends sms using SmsManager. How can I get informations about success of this operation? Is there a BroadcastReceiver for "sms sent" events? Thank you in advice
supergiox
  • 1,586
  • 7
  • 19
  • 27
1 2 3
99
100