android-alarms

Android Galaxy S4 — Activity that is visible over lock screen

坚强是说给别人听的谎言 提交于 2019-11-27 01:53:55
问题 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

Alarm Manager - Scheduling multiple Non-repeating events

删除回忆录丶 提交于 2019-11-27 00:37:18
问题 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

Alarm Manager does not work in background on Android 6.0

给你一囗甜甜゛ 提交于 2019-11-26 22:58:27
问题 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,

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

穿精又带淫゛_ 提交于 2019-11-26 18:43:22
问题 @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();

Service being re-Created by AlarmManager

喜你入骨 提交于 2019-11-26 16:57:27
问题 I have a fairly standard Service which I wish to trigger using an alarm. Here's the initiation section of the service: class MyService extends Service { private Context context; private AlarmManager alarmManager = null; private final String startReason = "com.stuff.myreason"; private final int REASON_NO_INTENT = 0; private final int REASON_ALARM = 1; private final int REASON_X = 2; // and so on. @Override void onCreate() { super.onCreate(); context = getApplicationContext(); alarmManager =

Start AlarmManager if device is rebooted

心不动则不痛 提交于 2019-11-26 15:59:42
问题 In my app I want to run some code every day at a specific time using an AlarmManager . In the android documentation I found this: Registered alarms are retained while the device is asleep [...] but will be cleared if it is turned off and rebooted. And that is the problem. I want to run the code even if the user reboots the phone. If the user reboots the phone he currently has to relaunch my app to start alarms again. How can I prevent this? Is there a better mechanism I should use instead?

Samsung “App optimisation” feature kills background applications after 3 days

假装没事ソ 提交于 2019-11-26 14:19:08
问题 We are currently developing an Android app that is a fitness-tracker application. It runs constantly in the background, and it works fine on most devices, but we've been having issues with the application dying completely on some Samsung devices. After some investigation, it seems like some Samsung devices has a completely custom "App Optimisation" feature (http://forums.androidcentral.com/samsung-galaxy-s6/599408-app-optimisation-after-updating.html), which is basically a (very) primitive

does Alarm Manager persist even after reboot?

一世执手 提交于 2019-11-26 13:08:54
I am really new to android, I have been researching about alarms. I want to alarm if there is a birthday on that day. I've have used alarm manager. I was confused because i have read that it clears after reboot. I don't have an android phone so I'm just using the emulator. Here's my code : public void schedAlarm() { AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); Intent intent = new Intent(this, AlarmService.class); pendingIntent = PendingIntent.getBroadcast(this, contact.id, intent, PendingIntent.FLAG_ONE_SHOT); am.setRepeating(AlarmManager.RTC, timetoAlarm, nextalarm,

How to setup Alertbox from BroadcastReceiver

感情迁移 提交于 2019-11-26 12:48:47
问题 I have implemented alarm in android app. Alarm is working fine. Toast message is visible. Now I want to make Alert Box Notification to user . Here is code from ReceiverActivity Class. which I tried public class ReceiverActivity extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub // Code.... new AlertDialog.Builder(context) .setTitle(\"Alert Box\") .setMessage(\"Msg for User\") .setPositiveButton(android.R.string.ok,

Running task periodicaly(once a day/once a week)

我怕爱的太早我们不能终老 提交于 2019-11-26 10:57:33
问题 I want to run some task (i.e. get my web site news page) periodically (once a week/ a day), even if my application is closed. Is it possible? 回答1: Yes it is, you need to look at the AlarmManager to setup a reoccurring "Alarm". This is better for battery life on the device, as unlike a service it does not run constantly in the background. The Alarm triggers a broadcast receiver which will execute your custom code. As a final note - there are enum values for the timing of the Alarm including