android-alarms

Lollipop API for controlling the Alarm icon in status bar

天涯浪子 提交于 2019-11-28 09:17:44
This is a Lollipop-specific question , since the API has changed. To find out how to do this on earlier versions, see related question: 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: Timely Alarm Clock controls this icon on Lollipop as of release 1.3. Prior to that release, the code was using private APIs as detailed in the related question . The new technique they use works on an unrooted Nexus 5 running v5.0.1. Update It looks like there is a lot more the this new API than just changing the

Android Galaxy S4 — Activity that is visible over lock screen

拥有回忆 提交于 2019-11-28 07:37:52
A few years ago, I wrote an alarm app that worked on Android 2, and I'm now trying to upgrade it to work on Android 4. Specifically, on the Samsung Galaxy S4. On Android 2, if the phone was sleeping, it would wake the phone up and display a "Snooze or Dismiss" screen over the lock screen. On Android 4, it wakes the phone up, but you have to unlock it, then open the notifications area, then click the alarm's notification, before you can hit "Dismiss." I have always been using this code to do the waking: getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager

Alarm Manager - Scheduling multiple Non-repeating events

家住魔仙堡 提交于 2019-11-28 04:43:33
In Android Alarm Manager, how can we schedule multiple alarms which are non-repeating and do not have fixed intervals to repeat? I cannot use 'setRepeating' function as the alarms don't have any repeating pattern. I have the alarm times stored in Sqlite database table and the activity should pick the date and time from this table and set the alarms. If we setup different alarms in a loop, then it retains only the last one. I read from the post: How can create more than one alarm? It tells to attach the unique Id to the intent and then setting up individual alarm events. But it didn't work for

Identify and cancel an alarm send to an AlarmManager

喜欢而已 提交于 2019-11-28 02:28:20
问题 If I use the AlarmManager to schedule an alarm (a PendintIntent which should be send), how can I identify that alarm later to cancel it? Can I cancel all alarms scheduled by my app? 回答1: You probably want to have a closer look at the AlarmManager.cancel(PendingIntent operation) function. 来源: https://stackoverflow.com/questions/4212824/identify-and-cancel-an-alarm-send-to-an-alarmmanager

Repeat Alarm once in a week in android

时光总嘲笑我的痴心妄想 提交于 2019-11-28 01:21:27
问题 I am trying to develop alarm functionality in a my app which runs on a week days specified by user on fixed time. Problem here is that my scheduler running for all days instead of running on specified day . here is the code i wrote for this please help to fix this Calendar calNow = Calendar.getInstance(); SimpleDateFormat simpDate; simpDate = new SimpleDateFormat("kk:mm:ss"); if(in_Date==1) { calNow.set(Calendar.HOUR_OF_DAY, hourOfDay); calNow.set(Calendar.MINUTE, minute); calNow.set(Calendar

BroadcastReceiver and AlarmManager Android

旧城冷巷雨未停 提交于 2019-11-28 01:11:17
问题 I am trying to use an alarm manager with BroadcastReceiver. I try to use the example given in Tutorial: System Services and BroadcastReceiver . but when I run the example after the end of the time the toast doesn't show up. the code is below: My main Activity: public class AlarmActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_alarm); }

AlarmManager not working in sleep mode

倾然丶 夕夏残阳落幕 提交于 2019-11-27 22:27:42
问题 I have set an AlarmManagr with a repeat time. Here is my method by which I am setting it: public void setAlarmManager(Context context, Intent intent) { PendingIntent pendingIntent; pendingIntent = PendingIntent.getService(context, 0, intent, 0); AlarmManager alarmManager = (AlarmManager)context.getSystemService(context.ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 10); alarmManager.setRepeating

Programmatically turn screen on in android

岁酱吖の 提交于 2019-11-27 21:00:00
问题 I am developing an alarm application. From the main activity i set the alarm using broadcast. Then in onReceive in broadcast receiver i call activity that is enabling user to shut down or snooze the alarm...In that activity, in the beginning of onCreate i use this lines to turn screen on and unlock the device: final Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); win.addFlags(WindowManager

Alarm Manager does not work in background on Android 6.0

霸气de小男生 提交于 2019-11-27 20:45:31
This is my Activity code, Long time = new GregorianCalendar().getTimeInMillis()+20000;//Setting alarm after 20 sec Intent intentAlarm = new Intent("alarm"); intentAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentAlarm.putExtra("req_code",10); PendingIntent pendingIntent = PendingIntent.getBroadcast(context,10, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent); These are all the permissions that I have in my app, <uses-permission android:name=

How do I make the AlertDialog box appear outside the app?

亡梦爱人 提交于 2019-11-27 16:28:01
@Override public void run() { //Create thread that can alter the UI AlarmPage.this.runOnUiThread(new Runnable() { public void run() { cal = Calendar.getInstance(); //See if current time matches set alarm time if((cal.get(Calendar.HOUR_OF_DAY) == alarmTime.getCurrentHour()) && (cal.get(Calendar.MINUTE) == alarmTime.getCurrentMinute())){ //If the sound is playing, stop it and rewind if(sound.isPlaying()){ ShowDialog(); alarmTimer.cancel(); alarmTask.cancel(); alarmTask = new PlaySoundTask(); alarmTimer = new Timer(); alarmTimer.schedule(alarmTask, sound.getDuration(), sound.getDuration()); }