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

Send data from BroadcastReceiver to ViewModel

My first question is where should I put my BroadcastReceiver class in a clean architecture project ? (Right now I put it inside data layer) My project packages defined as below ├──data └──repositories ├──di ├──domain └── repository └──…
2
votes
1 answer

PendingIntent.getBroadcast() never returns null

I am trying to find the PendingIntent of my BroadcastReceiver that was called using an AlarmManager. I am using PendingIntent.getBroadcast() using the very same arguments that it was called with, however it never returns null. public…
Tyler
  • 19,113
  • 19
  • 94
  • 151
2
votes
1 answer

BroadcastReceiver Intent delivered without extras

My BroadcastReceiver is not receiving the Intent extras when it gets delivered. Here's how I create the PendingIntent private fun getPendingIntent(type: ReminderType, date: DateTime): PendingIntent { val context = App.appContext val intent =…
Guy
  • 6,414
  • 19
  • 66
  • 136
2
votes
1 answer

Install new apk after download by Download Manager and exit from running app

I have create android app using java. But i want upgrade my app without playstore. I try to download manually but it make more time to do that. I want make it simply. So i use download manager for download new file from my server. And now i donno…
2
votes
1 answer

android broadcastreceviver onreceive action not performed

I wanted to create a broadcastreceiver which listens for android.intent.action.MEDIA_BUTTON, and get the extra_key_event from that and act accordingly. Somehow the onreceive action is not performed. In my Manifest: receiver…
kevdliu
  • 1,709
  • 4
  • 29
  • 46
2
votes
4 answers

help required with BroadcastReceiver

Basically, my problem is that i need to send data from my service (started with Intent) to my main activity. (this is my first attempt at using a BroadcastReceiver) I have two apps, com.example.myapp (contains main activity) and…
92Jacko
  • 523
  • 2
  • 10
  • 18
2
votes
2 answers

BroadcastReceiver Priority issue

I am implementing SMSListener in my app and I have set it's possibly highest priority as android:priority="2147483647" so that I should get the call on new incoming sms. In my second sample app I have set the same priority as above for SMSListener…
Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
2
votes
1 answer

differentiate between button clicks using pending intent

I am showing a custom notification (FCM). custom notification has two buttons approve and deny. I have managed to create pending intent and a broadcast receiver and now I know in onReceive when the button is clicked. How can i differentiate between…
2
votes
1 answer

Unable to get package name of chosen third party app with PendingIntent.FLAG_IMMUTABLE

I need to get the name of the app chosen by user fired with Intent.ACTION_SEND for analytic purposes. The name of app will be obtained through BroadcastReceiver. It works until one day, the security engineer in our team informed us that all…
flamyoad
  • 519
  • 7
  • 15
2
votes
2 answers

Broadcast Receiver and Internet connection

How do I use broadcast receiver to check if there isn't Internet connection? And after that: 1.If there is connection = do nothing 2.There isn't connection = open new activity I hope you understand what I'm asking about. Here is my webview app…
Eljas
  • 1,187
  • 4
  • 17
  • 37
2
votes
2 answers

BroadcastReceiver not receiving any activity recognition broadcast

My main activity registering broadcast for Activity Recognition but and don't see any calls to Broadcast Receiver's onReceive method. I am not able to figure out why it's not working as expected. I am testing on Real device with android 11 (API 30)…
Ritu
  • 518
  • 2
  • 12
  • 35
2
votes
1 answer

How to have a Manifest-declared broadcast receiver communicate with an activity or service?

This should be obvious but I can't find the solution. Many people have asked it and the reply is usually to just switch to a context-registered receiver instead. I have an accessibility service which needs to be notified when the Manifest-declared…
user15603244
2
votes
0 answers

Broadcast gives multiple fires on using PROVIDERS_CHANGED_ACTION - SOLUTION

Hello guys I am using Broadcast Receiver in my project that gives me multiple outputs at one time while enabling and disabling GPS. How to solve that?? Here is a log that will give multiple outputs like this MyBroadcastReceivers﹕ IsGPS =…
Manish
  • 170
  • 9
2
votes
2 answers

Android Sleep API - not getting data

I use the Sleep API in my Kotlin Android app. To get sleep data, I am following these steps: Getting the android.permission.ACTIVITY_RECOGNITION permission from the user Successfully registering to both SleepSegmentEvent and…
2
votes
1 answer

Android Broadcast Receivers: Can they execute simultaneously or do they always execute consecutively?

I have a little confusion with broadcast receivers. I have a broadcast receiver which is triggered upon TIME_SET and TIMEZONE_CHANGED actions (the code is given below). What I was wondering is, can OnDateTimeChanged (see the code below) be triggered…
ali.chousein
  • 95
  • 1
  • 1
  • 10
1 2 3
99
100