broadcastreceiver

Broadcast receiver working even after app is killed by user

纵然是瞬间 提交于 2021-02-18 15:30:11
问题 I have a BroadcastReceiver that checks for network connection declared statically as: <receiver android:name=".core.util.NetworkChangeReceiver" android:label="NetworkChangeReceiver"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="android.net.wifi.WIFI_STATE_CHANGED" /> </intent-filter> </receiver> Network change receiver does something like: public class NetworkChangeReceiver extends BroadcastReceiver { @Override public void onReceive

passing data from BroadcastReceiver to Service

强颜欢笑 提交于 2021-02-10 22:32:13
问题 My goal is to create a method that gets the data from broadcast receiver. I have a service that register a BroadcastReceiver to monitor battery plug and unplug. How can i get data from BroadcastReceiver ? I want to receive data in this service class: Service: public class myService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { registerReceivers(); return START_NOT_STICKY; } @Nullable @Override public IBinder onBind(Intent intent) { return null;

passing data from BroadcastReceiver to Service

喜欢而已 提交于 2021-02-10 22:19:19
问题 My goal is to create a method that gets the data from broadcast receiver. I have a service that register a BroadcastReceiver to monitor battery plug and unplug. How can i get data from BroadcastReceiver ? I want to receive data in this service class: Service: public class myService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { registerReceivers(); return START_NOT_STICKY; } @Nullable @Override public IBinder onBind(Intent intent) { return null;

How can a closed application receive periodic broadcasts?

孤街醉人 提交于 2021-02-10 14:14:26
问题 I have a device with Android 9 and I am developing an application that displays content depending on the current date and time. I would like it to regularly check whether new content is available and inform the user about it. Additionally I would like that to work also when the user closes the application. My email application here for example shows notifications about new emails also when it's closed. My approach has been to receive general broadcasts ( Intent.ACTION_USER_PRESENT and Intent

Android receiver ignore NEW_OUTGOING_CALL

独自空忆成欢 提交于 2021-02-10 14:14:24
问题 I have a with Broadcastreceiver with an intent-filter to catch android.intent.action.NEW_OUTGOING_CALL. I read many tutorials and answer here about handling NEW_OUTGOING_CALL intent, but I was unable to make this thing works. My goal is to log intent android.intent.action.NEW_OUTGOING_CALL received by my Broadcastreceiver. I'm unable to make this simple thing works. Here's my code: Manifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res

How to catch GPS off broadcast once?

穿精又带淫゛_ 提交于 2021-02-10 07:16:06
问题 I have surfed the web and I haven't found a solution to my problem. In my android app I have to catch and send a notification to the server everytime the user turn off the GPS. At this time I have writed this code In the Android manifiest: <receiver android:name="proguide.prosegur.scr.BL.receivers.GPSStatusBroadcastReceiver"> <intent-filter> <action android:name="android.location.PROVIDERS_CHANGED" /> </intent-filter> </receiver> In the GPSStatusBroadcastReceiver class: public class

Sending Extras to onReceive only retrieves ALARM_COUNT

笑着哭i 提交于 2021-02-10 07:03:19
问题 I made a custom view that sets an alarm with AlarmManager. I want to restore this view later so I'm trying to send the BroadcastReceiver several extras. The onReceive fails to retrieve anything but the ALARM_COUNT extra though. I've looked for a while and count find a solution. I've tried PendingIntent.FLAG.UPDATE.CURRENT multiple flags with the intent itself but nothing works. Is there a better way to restore a views state from a BroadcastReceiver? 回答1: "extras are all serialized into a byte

Sending Extras to onReceive only retrieves ALARM_COUNT

感情迁移 提交于 2021-02-10 07:01:21
问题 I made a custom view that sets an alarm with AlarmManager. I want to restore this view later so I'm trying to send the BroadcastReceiver several extras. The onReceive fails to retrieve anything but the ALARM_COUNT extra though. I've looked for a while and count find a solution. I've tried PendingIntent.FLAG.UPDATE.CURRENT multiple flags with the intent itself but nothing works. Is there a better way to restore a views state from a BroadcastReceiver? 回答1: "extras are all serialized into a byte

Broadcastreceiver for a downloaded image

喜你入骨 提交于 2021-02-08 10:14:51
问题 Basically I want to set a Broadcastreceiver that gets triggered when the user downloads an image into gallery/phone from chrome, facebook, twitter..etc when the photo is finished downloading , and the actions is triggered, I want access to the downloaded image for extra work such as editing and stuff..! I'm thinking this can be accomplished by Broadcastreceiver , that listens for the image and then do the actions that needed..! I've tried to search for action to be added in the Manifest

Get incoming call number programmatically on android

偶尔善良 提交于 2021-02-08 08:06:34
问题 I am trying to get incoming call info using broadcast receivers on android studio. following are the methods i tried: <receiver android:name=".receivers.IncomingCalls"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver> On this receiver's intent i tried: Method one: incnumber=intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); Method two: final String state1 = intent.getStringExtra(TelephonyManager.EXTRA_STATE); telephony.listen