broadcastreceiver

Is there a way to keep a repeating alarm working after existing the app that uses a broadcast receiver?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 05:29:31
问题 I am new on Android. I am trying to create an application that uses BroadcastReceiver to execute a function on the main activity triggered by a repeating alarm. I read that I had to dynamically register the broadcastReceiver which I did - this is to be able to execute the function on the main activity. The problem I am faced with is that as soon as the app is exited, the alarm stops working. I read that this is by design - is there a way to overcome this or do I have to use a service ? Thanks

PendingIntent.getBroadcast() never returns null

孤街浪徒 提交于 2019-12-11 05:29:00
问题 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 MyObject(Context context, AnotherObject object) { Intent i; i = new Intent(context, MyReceiver.class); i.putExtra(AnotherObject.SOMETHING, "string"); i.putExtra(AnotherObject.SOME_BOOL, true); PendingIntent pi = PendingIntent.getBroadcast(context, 0, i,

How to update ListView from BroadcastReceiver?

浪子不回头ぞ 提交于 2019-12-11 05:23:45
问题 It was perfectly fine to update just a TextView , but when I tried to update a ListView from onReceive , I kept getting NullPointerException from getView method ( BaseAdapter ). I have tried both handler.post & runOnUiThread but the problem remains the same. Did I miss something? public class MainActivity extends Activity { private SimpleBroadcastReceiver receiver; private List<User> users; private UserItemAdapter adapter; private ListView listview; @Override protected void onCreate(Bundle

How to send a data from a broadcast receiver to fragment?

本秂侑毒 提交于 2019-12-11 05:20:02
问题 How to send a data from a broadcast receiver to fragment? Here I want to send the phonenumber (OriginatingAddress) to another fragment. public void onReceive(Context context, Intent intent) { Bundle intentExtras = intent.getExtras(); if (intentExtras != null) { Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE); String smsMessageStr = ""; for (int i = 0; i < sms.length; ++i) { SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]); String smsBody = smsMessage.getMessageBody()

Android 6.0 Broadcast Receiver don't receive BOOT_COMPLETE

ぐ巨炮叔叔 提交于 2019-12-11 05:14:45
问题 My receiver is not working with Android 6.0 Marshmallow . I am sending a broadcast through adb shell, see below: adb shell am broadcast -a android.intent.action.BOOT_COMPLETED received if application was open, App say:Working! But if the application was not open, it has not been returning anything. My code is here; AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.berate.rebootreceiverfromb3r0">

Connectivity Change Broadcast receiver not triggering when phone is in sleep mode

喜夏-厌秋 提交于 2019-12-11 05:14:02
问题 I have a network state change Broadcast Receiver setup for my app. I need to receive wifi connect-disconnect events even when phone is in sleep mode. This works when phone is charging and in sleep, but doesn't when its not in sleep. here is code public class NetworkConnectionReceiver extends WakefulBroadcastReceiver { public static final String INTENT_CONNECTIVITY_CHANGE = "android.net.conn.CONNECTIVITY_CHANGE"; @Override public void onReceive(Context context, Intent intent) { if (intent

Broadcast receiver on app closed (or in the background)

心已入冬 提交于 2019-12-11 04:44:56
问题 I create a simple alarms app and I have two broadcast receivers registered in AndroidManifest.xml (One for receiving alarms and other for rescheduling them on device boot). After scheduling some alarms I reboot my device and my "OnBoot" receiver rescheduling alarms well, but the first receiver doesn't recive them. If I start my app, schedule some alarms and won't close it, the receiver will work fine, but if I close (not force stop) app or send it into background by pressing the home button ,

DATE_CHANGED Broadcast is not being fired

好久不见. 提交于 2019-12-11 04:44:20
问题 I have one DATE_CHANGED BroadcastReciever in my application but it seems its not firing up at mid night instead its firing my myreciever at 12.00 day time. i have declare this in manifest file as <receiver android:name=".DateChangedReceiver" > <intent-filter> <action android:name="android.intent.action.DATE_CHANGED" /> </intent-filter> </receiver> and my DateChangedReceiver.java file is like public class DateChangedReceiver extends BroadcastReceiver { @Override public void onReceive(Context

BroadcastReceiver and AlarmManager not working with

北城以北 提交于 2019-12-11 04:39:13
问题 I've been trying to fix this for hours but I still don't get it. My code is very basic: BroadcastReceiver public class TimerNotif extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { notificationStatus(context); } private void notificationStatus(Context context) { final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); final int icon = R.drawable.ic_launcher; final Notification

What is the right way of static registration of custom Broadcast receiver in Android?

穿精又带淫゛_ 提交于 2019-12-11 04:35:49
问题 Instead of dynamic registration, I want to statically register my receiver. For dynamic registration, it works well, I was using this : .. static private IntentFilter GPSActionFilter; .. GPSActionFilter = new IntentFilter("GGPS Service"); context.registerReceiver(GPSActionReceiver, GPSActionFilter); .. static private BroadcastReceiver GPSActionReceiver = new BroadcastReceiver(){ public void onReceive(Context context, Intent intent) { ..} For static registration, debugger never hits the