alarmmanager

Start Android Service after every 5 minutes

一笑奈何 提交于 2019-12-17 10:34:39
问题 I was searching over the internet for last 2 days but I couldn't find any tutorial helpful. I have created a service and I am sending a notification in status bar when the service starts. I want that service to stop after showing the notification and start it again after 5 minutes. Please let me know if it is possible and provide me some helpful tutorials if you have any. I heard of TimerTask and AlarmManager and I tried to use them as well but I wasn't able to get the desired result. EDIT: I

Android exact Alarm is always 3 minutes off

假装没事ソ 提交于 2019-12-17 10:29:08
问题 I have an app which uses the AlarmManager to regularly wake up the phone at full hour and send a message to an Android Wear watch which than makes a short vibration. I have two users with a Samsung Galaxy S6 with stock Android 5.1.1 and the Sony SW 3 with 5.1.1 who experience a weird bug. At the very first full hour the vibration is at the exact time but all other vibrations are 3 minutes delayed. Sometimes even the first full hour vibration is delayed. Here is some code: final Calendar time

Controlling the Alarm icon in status bar

邮差的信 提交于 2019-12-17 09:55:24
问题 This question relates to Android versions pre-Lollipop. For Lollipop API, check related question: Lollipop API for controlling the Alarm icon in status bar I would like to know how to turn on / off the system Alarm icon in the status bar as shown in this image: From what I understand about the system, and what I've read in the past, it is controlled by the built in system alarm clock app. And 3rd party apps have no control over it on an unrooted device. There is no reason we should be able to

Is it possible to create multiple PendingIntents with the same requestCode and different extras?

ε祈祈猫儿з 提交于 2019-12-17 09:00:09
问题 I'm using AlarmManager to schedule anywhere between 1 and 35 alarms (depending on user input). When the user requests to schedule new alarms, I need to cancel the current alarms, so I create all of my alarms with the same requestCode, defined in a final variable. // clear remaining alarms Intent intentstop = new Intent(this, NDService.class); PendingIntent senderstop = PendingIntent.getService(this, NODIR_REQUESTCODE, intentstop, 0); am.cancel(senderstop); // loop through days if (sched

setExactAndAllowWhileIdle - is not exact as of developer reference

ⅰ亾dé卋堺 提交于 2019-12-17 07:11:08
问题 AlarmManager on API19 has the method setExact() to set an exact alarm. Exact means --> If I set an alarm to 2:01 pm it will be triggered at 2:01 pm On API 23 - Marhsmwallow (6.0) there is a new method setExactAndAllowWhileIdle() , but as of the reference it is not EXACT because it will trigger only every minute and in low power idle mode only every 15 minutes . Exact != every 15 minutes :-) So how can I achieve an exact alarm with AlarmManager in 6.0 ? If a user adds a reminder or a calendar

AlarmManager Android Every Day

喜夏-厌秋 提交于 2019-12-17 06:24:19
问题 I'm trying to make a Schedule. It should run every day at 1pm or 2pm... At the moment I can only make it run Every 10Sec or 10min... Intent myIntent = new Intent(AndroidAlarmService.this, MyAlarmService.class); pendingIntent = PendingIntent.getService(AndroidAlarmService.this, 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND

android AlarmManager not waking phone up

戏子无情 提交于 2019-12-17 04:52:38
问题 I want an activity to be displayed at a certain time. For this, I am using AlarmManager. It works fine when the device is awake, but it doesn't wake it up if it's asleep. My code for setting the alarm: Calendar alarmTime = Calendar.getInstance(); alarmTime.set(Calendar.HOUR_OF_DAY, alarm.hour); alarmTime.set(Calendar.MINUTE, alarm.minute); alarmTime.set(Calendar.SECOND, 0); if (alarmTime.before(now)) alarmTime.add(Calendar.DAY_OF_MONTH, 1); Intent intent = new Intent(ctxt, AlarmReceiver.class

How to make Alarm Manager work when Android 6.0 in Doze mode?

*爱你&永不变心* 提交于 2019-12-17 02:35:16
问题 I am a developer of two alarm clock apps on Google Play. I am trying to get them to work with Android 6.0. However, Doze mode makes it so they do not ring. I put them on the white list, I put a foreground notification icon up, I'm not sure what else I can do - when in Doze mode, the the Alarm Manager alarms are still ignored. The Clock app (which is a Google Play rather than AOSP app), however, is different. When the alarm is enabled on the Clock app, "adb deviceidle step" will always read

Calling startActivity() from outside of an Activity?

痞子三分冷 提交于 2019-12-17 02:26:05
问题 I'm using an AlarmManager to trigger an intent that broadcasts a signal. The following is my code: AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(this, Wakeup.class); try { PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0); Long elapsed += // sleep time; mgr.set(AlarmManager.RTC_WAKEUP, elapsed, pi); } catch(Exception r) { Log.v(TAG, "RunTimeException: " + r); } I'm calling this code from an Activity , so I don't know how I could be

Alarmmanager does not fire Service after more than 1 Hour - or when the app is in doze… - Android Oreo [closed]

风流意气都作罢 提交于 2019-12-14 03:25:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 months ago . I try to set up an alarm with Alarmmanager and fire a service five times. I try to fire it after 30 minutes after the time is set. After 1 hour, after 2 hours, 3 hours and 5 hours - but it does not really work... I tried alarmmanager.setAlarmClock --> it does not work... alarmmanager.setExactAndAllowWhileIdle -