alarmmanager

How to programmatically detect SONY - Stamina device energy profile is ON

二次信任 提交于 2019-12-04 02:56:57
I want to notify user that my app will not work properly if he has SONY android phone with STAMINE energy profile ON. This profile is blocking AlarmManager and device is not waked up when I want. Currently, there is no official way to detect if the STAMINA energy profile is selected. However, if there is enough community demand we may be able to open this up. You could check it via Settings.Secure.getInt(contentResolver, "somc.stamina_mode", 0) == 1 Works at least on the Sony Xperia XZ1 Compact (8.0.0) 来源: https://stackoverflow.com/questions/18845479/how-to-programmatically-detect-sony-stamina

Android. Alarm Manager fires in strange times

ε祈祈猫儿з 提交于 2019-12-04 02:35:38
I used the following code to set repeating alarm (every 5 minutes). public void SetAlarm(Context context) { AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, Alarm.class); PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0); am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 60 * 5, pi); // Millisec * Second * Minute } Is seems to work fine (it runs almost 20 hours), and in the server I can see that some constant message arrives. However, there is something about the times: I want the times to be

How can repeating AlarmManager start AsyncTask?

陌路散爱 提交于 2019-12-04 02:13:05
问题 I usually write this code to start a service with AlarmManager . intent = new Intent(getActivity(), someservice.class); pendingNotificationIntent = PendingIntent.getService(getActivity(), 0, intent, 0); alarm = (AlarmManager) getActivity().getSystemService(getActivity().ALARM_SERVICE); int interval = 30 * 1000; long now = Calendar.getInstance().getTimeInMillis(); alarm.setRepeating(AlarmManager.RTC_WAKEUP, now, interval, pendingNotificationIntent); My AsyncTask is a private class where I

Android background services and alarms

折月煮酒 提交于 2019-12-04 02:07:50
问题 Recently encountered with a problem when Android 4.4 killed my app's Service and AlarmManager when device going into a sleep mode ( START_STICKY param doesn't helps). I tried a lot of things, but nothing works as I need. In my task manager app I always see a lot of processes of non-default apps such as Google+, Skype, Google Drive end some else that working in real time and never were killed by the system. I want to ask more experienced developers how to create Service or Alarm that will not

Service run on specific Time Android

送分小仙女□ 提交于 2019-12-04 01:59:55
问题 I am trying to run service on every day only on Specific time, lets say every day 8 :00 am and here I found two methods as public static void setScheduleMessage(Context context, int hours, int minuts, int seconds) { Calendar calendar = Calendar.getInstance(); // 8 AM calendar.set(Calendar.HOUR_OF_DAY, hours); calendar.set(Calendar.MINUTE, minuts); calendar.set(Calendar.SECOND, seconds); PendingIntent pendingIntent = PendingIntent.getService(context, 0, new Intent(context,

Time/Date change listener

人盡茶涼 提交于 2019-12-03 22:51:57
问题 I want to make a time or date listener which for example invoke an activity every day at 9 AM. I am not sure what is the best way to do that? I know I can use Alarm Manager, but I don't know how to make it repetitive? Does anyone know? Thank you very much in advance. Cheer :) 回答1: I know I can use Alarm Manager, but I don't know how to make it repetitive? Use setRepeating() and specify a repeat interval of INTERVAL_DAY: static void scheduleAlarms(Context ctxt) { AlarmManager mgr=(AlarmManager

AlarmManager delete all schedules on power-off?

谁说胖子不能爱 提交于 2019-12-03 21:53:21
问题 I have set an alarm at specific time. If the phone is turn off the alarm is lost? I have turn off the phone, start it again but the alarm did not trigger at the specified time. PendingIntent pendingIntent = PendingIntent.getBroadcast( Global.a.getApplicationContext(), (int) cd.e.alarmTime, intent, 0); AlarmManager alarmManager = (AlarmManager) Global.a.getSystemService(Activity.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC, cd.e.alarmTime, pendingIntent); 回答1: First you need to create a

How to run a retry when download fails in AsyncTask using AlarmManager

南笙酒味 提交于 2019-12-03 21:26:35
I use an AlarmManager to run a Service which tries to download a file from the web. If it fails I'd like to retry that Service in 5 minutes. Inside the Service I run an AsyncTask to run my code. As far as I know the only way I can tell if it failed or not is from the onPostExecute() . What is the best way of implementing a retry of that Service again? Falmarri's answer is the correct one, and I do not understand your concerns. In onPostExecute() , when you determine that things went awry: Call getSystemService(ALARM_SERVICE) to get the AlarmManager Call set() on the AlarmManager to trigger you

AlarmManager is not triggered when App is closed

有些话、适合烂在心里 提交于 2019-12-03 20:40:55
I have some in-App notification to show to users at a specific time but nothing is shown when the App is closed. Setting alarm: Intent alarmIntent = new Intent(mMotherActivity, ReminderAlarmManager.class); if (ReminderNotificationType.CHANGE_LENS.equals(notificationType)) { alarmIntent.putExtra("NOTIFICATION_TYPE", "REMINDER"); } else { alarmIntent.putExtra("NOTIFICATION_TYPE", "ORDER"); } long scTime = alarmDate.getTime(); PendingIntent pendingIntent = PendingIntent.getBroadcast(mMotherActivity, 0, alarmIntent, 0); AlarmManager alarmManager = (AlarmManager) mMotherActivity.getSystemService

Android AlarmManager: is there a way to cancell ALL the alarms set?

流过昼夜 提交于 2019-12-03 19:54:37
问题 I am building an app that set 2 alarms for each day of the week (at a certain hour and minute), the alarms repeat week after week forever. Now the point is: if the user changes the alarms, I will need cancel the previously set alarms. Is there a way to simply cancel all the alarms set by my application ? 回答1: I think you could get an eye on : AlarmManager.Cancel And on that Question/Answer: Android: Get all PendingIntents set with AlarmManager As stated in there you can't ask to the