android-alarms

setAlarmClock not exact in android marshmallow

≡放荡痞女 提交于 2019-12-22 00:05:58
问题 I use setAlarmClock method of Alarmmanager for do alarm clock application. When I set alarm clock from 6.00 AM and alarm in 6.01 AM . It delay and not exact. Code when setAlarmClock . Intent intent = new Intent(getBaseContext(), AlarmReceiver.class); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.putExtra(AppConstant.REMINDER, note.convertToString()); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), note.getId(), intent, PendingIntent.FLAG_CANCEL

detect default alarm clock application alarms

≯℡__Kan透↙ 提交于 2019-12-21 08:17:08
问题 I would like to know if there is a way (probably a system broadcast) to know that the alarm clock default application is now start ringing. if not - I'll be satisfied also if I could get progrematically list of all active alarms been set by the user(which I could extract from each alarm the exact time it would ring..) what I tried so far: I know there is a way to get formatted string to next alarm: String nextAlarm = Settings.System.getString(context.getContentResolver(), Settings.System.NEXT

Updating a widget only when device is on AND widget is visible on home screen

无人久伴 提交于 2019-12-21 04:25:30
问题 As far as I understood the official documentation about Widgets I am a little bit confused. The "standard" way would be to define a BroadcastReceiver and define the update frequency in milliseconds - this way allows a minimum update interval of 30 minutes to save battery power. Sounds reasonable. The "manual" way I found reading the Google documentation would be to handle the update of widgets yourself using the AlarmManager . Using this method higher update intervals are possible (though of

Schedule an event to be executed in future (Cron Job the Android way)

时光总嘲笑我的痴心妄想 提交于 2019-12-21 02:40:56
问题 I have certain dates which once attained lose their relevance and new dates for these fields in the DB should be calculated, I know I can leverage the AlarmManager class for this, however I have a few concerns regarding this: 1) Note: Beginning with API 19 (KITKAT) alarm delivery is inexact: the OS will shift alarms in order to minimize wakeups and battery use. There are new APIs to support applications which need strict delivery guarantees; see setWindow(int, long, long, PendingIntent) and

How can I set exact, repeating alarms in Android 4.4?

你。 提交于 2019-12-20 10:49:12
问题 Right now, I am setting alarms like this: AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); timedate = cal.getTime(); //convert date to milis long timeInMilis = (timedate.getTime()); //Set Alarm to Repeat manager.setRepeating(AlarmManager.RTC_WAKEUP, timeInMilis, interval, pendingIntent); Unfortunately, the scheduled times for

Can I set an end time for AlarmManager in Android?

风流意气都作罢 提交于 2019-12-20 03:18:33
问题 I have set up an AlarmManager to go off at a specific time, and then repeat in intervals. Is it possible to tell it after how many intervals to stop? Or even at what time to stop? This is what I have so far: Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 13); calendar.set(Calendar.MINUTE, 56); Intent intent = new Intent(this, MyService.class); alarmIntent = PendingIntent.getService(this, 0, intent, 0);

How can create more than one alarm?

时光总嘲笑我的痴心妄想 提交于 2019-12-19 19:39:33
问题 I am able to create and cancel an alarm with the code below. I want to create more than one alarm. Alarm times comes from an arraylist. In this arraylist I would like to create an alarm for each date. And presses of the cancel button will cancel only the current alarm. How can I do it? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

How to launch Alarm Clock screen using Intent in Android?

♀尐吖头ヾ 提交于 2019-12-18 18:12:13
问题 In my application, i want to add alarm using my App. So i want to launch the add alarm screen of the phone directly from my App. So how to launch it using Intent? 回答1: The following code starts an AlarmClock activity: Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); i.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm"); i.putExtra(AlarmClock.EXTRA_HOUR, 10); i.putExtra(AlarmClock.EXTRA_MINUTES, 30); startActivity(i); You also need to use the following permission: com.android.alarm.permission

How to get the number of alarms in Android phone?

不想你离开。 提交于 2019-12-18 09:40:58
问题 I am trying to use the following code to get the number of alarms currently set on the phone. Uri uri = Uri.parse("content://com.android.deskclock/AlarmClock"); Cursor c = getApplicationContext().getContentResolver().query(uri, null, null, null,null); But I get a NullPointerException when I try to fetch the number using int num = c.getCount(); System.out.println("No of alarms : "+c.getCount()); Please let me know what I am doing wrong ? The exception occurs in getCount() itself so I am not

Alarm “cancel” button not working correctly

做~自己de王妃 提交于 2019-12-18 09:36:29
问题 I have 2 buttons save and set alarm and cancel alarm which are meant to do exactly what they suggest. Inside onCreate declared variables final Intent alarmintent = new Intent(AlarmActivity.this, AlarmReceiver.class); final AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); final PendingIntent sender1 = PendingIntent.getBroadcast(getApplicationContext(), 2, alarmintent, PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA); Code inside Cancel Button