broadcastreceiver

Broadcast receiver onReceive() getting called multiple times

前提是你 提交于 2019-12-23 07:53:05
问题 I have a boot_completed receiver which gets notified on boot. <receiver android:name=".BootCompletedReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> But it appears to get called multiple times. I start a timer, and then a service, which leads to multiple timers, and then the service gets reset and runs again. Creating timer like this. This is not a repeating timer, is it?: private void setAlarm(Context context, long

Broadcast receiver onReceive() getting called multiple times

笑着哭i 提交于 2019-12-23 07:52:07
问题 I have a boot_completed receiver which gets notified on boot. <receiver android:name=".BootCompletedReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> But it appears to get called multiple times. I start a timer, and then a service, which leads to multiple timers, and then the service gets reset and runs again. Creating timer like this. This is not a repeating timer, is it?: private void setAlarm(Context context, long

Battery broadcast receiver doesn't work

末鹿安然 提交于 2019-12-23 05:59:31
问题 I don't know why, but my battery broadcast receiver doesn't work. AndroidManifest.xml <receiver android:name=".BatteryReceiver" android:enabled="true"> <intent-filter> <action android:name="android.intent.action.BATTERY_CHANGED" /> <action android:name="android.intent.action.BATTERY_LOW" /> </intent-filter> </receiver> BatteryReceiver.java public class BatteryReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int level = intent.getIntExtra(

Battery broadcast receiver doesn't work

最后都变了- 提交于 2019-12-23 05:59:11
问题 I don't know why, but my battery broadcast receiver doesn't work. AndroidManifest.xml <receiver android:name=".BatteryReceiver" android:enabled="true"> <intent-filter> <action android:name="android.intent.action.BATTERY_CHANGED" /> <action android:name="android.intent.action.BATTERY_LOW" /> </intent-filter> </receiver> BatteryReceiver.java public class BatteryReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int level = intent.getIntExtra(

Passing data from a BroadcastReceiver to MainActivity works correctly only once

六月ゝ 毕业季﹏ 提交于 2019-12-23 05:46:31
问题 I have a PushNotificationReceiver (extends BroadcastReceiver) and MainActivity . The receiver sends some data (for example string value " New value ") to the MainActivity via an Intent . Then MainActivity updates its TextView with this value. This works fine until I change this TextView value to some other value (for example reset it to " UNSPECIFIED ") and move the activity to background and to foreground again. The MainActivity is restored and its TextView contains " New value ", however I

Xamarin Android - How to schedule and alarm with a BroadcastReceiver

点点圈 提交于 2019-12-23 05:30:07
问题 (I'm asking here because I didn't get help at Xamarin forums) I'm creating an alarm with this code: Intent alarmIntent = new Intent(context, typeof(AlarmReceiver)); notificationClickIntent = PendingIntent.GetActivity(context, 0, new Intent(), 0); pendingIntent = PendingIntent.GetBroadcast(context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); am = (AlarmManager)Android.App.Application.Context.GetSystemService(Context.AlarmService); DateTime setTime = new DateTime(temp.Ticks + offset); /

Broadcast receiver is not working - why so?

时光毁灭记忆、已成空白 提交于 2019-12-23 05:26:06
问题 I'm studying Android. I try to implement a Custom static Broadcast Receiver but it is not working. I search for some issue from Google but I can't find something to solve this. I work on Android 7.0 Min Level 24 Target Level 28 In fact, MyStaticReceiver isn't launching when I start the Activity (no log) MyDynamicReceiver work perfectly Do you have a solution? AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"

GCM Regisration Id expiration time

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 05:25:30
问题 I'm struggling with the next issue about GCM. I read the document (GCM document) and saw the example by Google how to implement the GCM client within Android app but in the entire document there is no reference to expiration of Registration Id. I saw that question but the example there is not following the last update by Google to the GCM Demo App My questions are: Does a Regisration Id ever expire? If a Regisration Id expires, how can I know that (is there any event for that)? Thanks in

Is there any way to block SMS programmatically in Android KitKat?

寵の児 提交于 2019-12-23 04:43:52
问题 Is this completely and utterly impossible in android Kitkat since Google has made so many changes to the way messaging works? I have tried using broadcast receivers and abortBroadcast, but to no avail. 回答1: Is there any way to block SMS programmatically in Android KitKat? No. Starting with KitKat, the SMS_RECEIVED broadcast cannot be aborted, so any app with the RECEIVE_SMS permission can still listen for it and retrieve the incoming message. If your app is the default app, it can choose not

Start an Activity from a BroadcastReceiver with a result

馋奶兔 提交于 2019-12-23 04:13:28
问题 I can call an Activity from a BroadcastReceiver by this way: public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try { Intent i = new Intent(context, MyActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); Log.v(TAG, "alarm triggered"); } catch (Exception e) { Log.v(TAG, e.toString()); } } } This brings the app to the front and calls onResume() at the Activity. My problem is I can't determine