alarmmanager

Where to declair the alarm manager for updating a watchface in ambient mode?

懵懂的女人 提交于 2019-12-11 13:59:58
问题 I'm trying to add an AlarmManager to update a watch face on half minute intervals. This is for a ternary clock. This is my first time programming with Java or android studio. I'm following a guide at https://developer.android.com/training/wearables/apps/always-on.html The guide says to "declare the alarm manager and the pending intent in the onCreate() method of your activity" Should I use @Override public Engine onCreateEngine() { return new Engine(); } or @Override public Engine

AlarmManager not set or not firing on Marshmallow after certain time

只愿长相守 提交于 2019-12-11 12:58:08
问题 I have been successfully using the following construct to start an AlarmManager in some of my apps upto Android 5: Intent serviceIntent = new Intent(context, MyService.class); PendingIntent pi = PendingIntent.getService(context, alarmId, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT); DateTime inMinutes = (new DateTime()).plusMinutes(60); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, inMinutes.getMillis(), pi); But since

check if charged setAlarmClock of AlarmManager

江枫思渺然 提交于 2019-12-11 11:27:04
问题 The Lollipop API represents setAlarmClock method to charge an intent. to start in I can use this code: am.setAlarmClock(new AlarmManager.AlarmClockInfo(nexttime,pi), pi); to cancel: am.cancel(PendingIntent.getService(ctx, 0, intentS, 0)); but how to check whether it was already charged? In common case I can use this: boolean alarmUp = (PendingIntent.getBroadcast(ctx, 0, intent, PendingIntent.FLAG_NO_CREATE) != null); but what about this new method? Does it works properly for setAlarmClock on

Android Alarm Manager with Broadcast receiver

梦想的初衷 提交于 2019-12-11 10:44:22
问题 Hello I have my Alarm Manager to show a Notification. The problem is that once the alarm is triggered and the notification is shown, when the code of MainActivity(super.onCreate) is executed, it always triggers the notification. Here is my MainActivity which executes the Alarm. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initAlarm(); } private void initAlarm(){ Calendar calendar = Calendar

Android repeating alarm not repeating correctly

老子叫甜甜 提交于 2019-12-11 10:25:11
问题 I have an alarm that I am wanting to repeat around every 5 minutes. For testing purposes, I have it set to repeat once every 5 seconds instead, as such: AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService(getActivity().ALARM_SERVICE); Intent intent = new Intent(getActivity(), CoordinateAlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getService(getActivity(), 1, intent, 0); int repeatSeconds = 5; alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,

Android AlarmManager - Scheduling a recurring Intent to fire off twice a day

爱⌒轻易说出口 提交于 2019-12-11 10:18:55
问题 After reading lots of sample code into this matter, I'm trying to figure out the simplest way to achieve the following: I want to be able to schedule an Intent that calls back to my Alarm BroadcastReceiver, which in turn fires off my Service. However, I want to set up so that it calls said Intent twice a day and to only schedule the alarms if they haven't already been set (likewise for canceling the alarms). However, I am unsure if the following code is the correct way to set and cancel

Android: Alarm starts at wrong time

房东的猫 提交于 2019-12-11 09:55:14
问题 On some devices (even on some that, at least according to the manual, do not have a battery saver in the system, and the customers deny they installed one) the system broadcasts the Alarm Intent several hours later , only at the moment when the user switches the device on. If the users set the alarm in a few minutes, it works. If it is set in a few hours, it might work, might be off by a few minutes or hours, most likely the latter. This is getting on my nerves, as I always get the complaints

Stop a service at specific time

為{幸葍}努か 提交于 2019-12-11 08:57:33
问题 I am starting my service using below code repeatedly. My service starts at 8am everyday. And AlarmManager repeates at every 1 min. I want to stop this sevice at 6pm. how can I do this ? AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); PendingIntent loggerIntent = PendingIntent.getBroadcast(this, 0,new Intent(this,AlarmReceiver.class), 0); Calendar timeOff9 = Calendar.getInstance(); timeOff9.set(Calendar.HOUR_OF_DAY, 08); timeOff9.set(Calendar.MINUTE, 00);

Show “left time” until the alarm start

旧城冷巷雨未停 提交于 2019-12-11 08:20:23
问题 I whould like to create a alarm (AlarmManager) in Android. The alarm must show the left time until its finish. So the user click on "set alarm at 11 pm" and see in a TextView "alarm in xy hours/minuts/seconds". How can I achieve this? Thanks. 回答1: Try like this Calendar calendar = Calendar.getInstance(); Long preTime = calendar.getTimeInMillis(); // set alarm after 5 minute calendar.add(Calendar.MINUTE, 5); Long postTime = calendar.getTimeInMillis(); Long delay = postTime - preTime;

Android deleteIntent not working? What's wrong with my code?

末鹿安然 提交于 2019-12-11 07:57:47
问题 I'm trying to detect when one of my notifications is cleared (either by swiping it away individually, or through the "delete all" notifications button). I'm trying to dismiss an AlarmManager alarm, but so far, it hasn't been working for me. What's wrong with my code? onCreate(Bundle savedInstanceState) { ... NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notif = new Notification(R.drawable.flag_red_large, reminderName, System