alarmmanager

Android Training Sample- Scheduler Sample- unable to stop alarm

浪子不回头ぞ 提交于 2019-12-23 02:34:26
问题 I am using the sample code(Scheduler.zip) available on the Android developer training website- http://developer.android.com/training/scheduling/index.html Here's the code:- MainActivity.java /* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by

How do I check if AlarmManager has an alarm set with FLAG_ONE_SHOT

北城余情 提交于 2019-12-23 02:30:58
问题 If I create a PendingIntent with FLAG_ONE_SHOT, a subsequent PendingIntent with FLAG_NO_CREATE returns null. AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context,AlarmService.class); PendingIntent pi = PendingIntent.getService(context,this.getId(),intent,PendingIntent.FLAG_ON_SHOT); GregorianCalendar alarmtime = new GregorianCalendar(now.get(GregorianCalendar.YEAR),now.get(GregorianCalendar.MONTH),now.get(GregorianCalendar.DAY_OF

Android Alarm not triggering at exact time

穿精又带淫゛_ 提交于 2019-12-22 18:25:05
问题 I have a problem using AlarmManager to run an IntentService at an exact interval. First i want to mention that i know about the changes to alarms since API level 19 and i have a proper way of handling things: public static void setServiceAlarm(Context con, long offset, boolean isOn, long lastHandledStamp){ Intent i = new Intent(con, StService.class); Bundle extra = new Bundle(); extra.putLong(EXTRA_TIMESTAMP, lastHandledStamp); i.putExtras(extra); PendingIntent pending = PendingIntent

Intent.putExtras not consistent

血红的双手。 提交于 2019-12-22 15:39:58
问题 I have a weird situation with AlarmManager. I am scheduling an event with AlarmManager and passing in a string using intent.putExtra. The string is either silent or vibrate and when the receiver fires the phone should either turn of the ringer or set the phone to vibrate. The log statement correctly outputs the expected value each time. Intent intent; if (eventType.equals("start")) { intent = new Intent(context, SReceiver.class); } else { intent = new Intent(context, EReceiver.class); }

Intent.putExtras not consistent

丶灬走出姿态 提交于 2019-12-22 15:39:09
问题 I have a weird situation with AlarmManager. I am scheduling an event with AlarmManager and passing in a string using intent.putExtra. The string is either silent or vibrate and when the receiver fires the phone should either turn of the ringer or set the phone to vibrate. The log statement correctly outputs the expected value each time. Intent intent; if (eventType.equals("start")) { intent = new Intent(context, SReceiver.class); } else { intent = new Intent(context, EReceiver.class); }

Intent.putExtras not consistent

老子叫甜甜 提交于 2019-12-22 15:39:03
问题 I have a weird situation with AlarmManager. I am scheduling an event with AlarmManager and passing in a string using intent.putExtra. The string is either silent or vibrate and when the receiver fires the phone should either turn of the ringer or set the phone to vibrate. The log statement correctly outputs the expected value each time. Intent intent; if (eventType.equals("start")) { intent = new Intent(context, SReceiver.class); } else { intent = new Intent(context, EReceiver.class); }

Alarm Manager is not activating broadcast receiver?

試著忘記壹切 提交于 2019-12-22 14:59:30
问题 I am working on an application inwhich I am using AlarmManager for scheduling things. My Alarm is set. But this Alarm does not invoke BroadcastReceiver written to catch the event. I have searched a great deal but I have not found anything that solves the issue. I am posting my code, please have a look and see if I am missing something. AlarmManagerClass: public class ScheduleMessageManager { Context context; PendingIntent sender; AlarmManager am; public ScheduleMessageManager(Context context)

Android notifications multiple times

核能气质少年 提交于 2019-12-22 14:01:01
问题 I have notifications that remind user to take the medicine. When I add new times for taking medicines, for example, at 9:00 pm and 9:01 pm, only last notification is active. Here is my code: AddTime.java: (part) Cursor cursor2 = sqdb.rawQuery("SELECT Name FROM Medicine WHERE _id = " + mId, null); while(cursor2.moveToNext()) { med = cursor2.getString(cursor2.getColumnIndex("Name")); } //med - Name of medicine String sql = "SELECT _id FROM Time WHERE mId = "+mId+" AND Year = "+year+" AND Month

How to detect whether the phone connected to android auto

情到浓时终转凉″ 提交于 2019-12-22 10:59:29
问题 I'm developing an audio player application, and I need to determine when the user's device is connected to Android Auto. The application features an alarm, and I want to make sure it doesn't go off while the user is driving. To determine whether my music-service ( MediaBrowserService ) works, I can use some flags in onCreate and onDestroy, or register reciver for "com.google.android.gms.car.media.STATUS" action - but it's a bad idea because alarm clock can trigger in any time. And not only

How to Autostart an AlarmManager to start a Scheduled Activity?

我的梦境 提交于 2019-12-22 10:38:11
问题 This tutorial come from android-er, The main activity(AndroidScheduledActivity.java) start a AlarmManager to trigger BroadcastReceiver(MyScheduledReceiver.java) repeatly. In the onReceive() method of MyScheduledReceiver, it start another activity(MyScheduledActivity.java) indirectly. Such that the activity(MyScheduledActivity.java) will be start in scheduled interval. Now I would use AutoStart to start automatically, but I was not able to write the AutoStartNotifyReceiver . please can you