android-alarms

Set AlarmManager from DatePicker and TimePicker

江枫思渺然 提交于 2019-12-08 06:33:54
问题 I'm very stuck creating an alarm from a DatePicker and TimePicker... This is the code of my try: Calendar cal=Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth()); cal.set(Calendar.MONTH, datePicker.getMonth()); cal.set(Calendar.YEAR, datePicker.getYear()); cal.set(Calendar.HOUR, timePicker.getCurrentHour()); cal.set(Calendar.MINUTE, timePicker.getCurrentMinute()); long millis=cal.getTimeInMillis(); Intent intent=new Intent(CalendarView.this,AvisoReceiver.class);

AlarmManager alarm does not trigger after the phone resets

♀尐吖头ヾ 提交于 2019-12-08 02:29:41
问题 In my app the user joins a plan, then the next day at noon there is an alarm notification. Here is my code: First, I set an alarm in AlarmManager like so: //set alarm to the next day 12:00 noon of the join date SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { alarm_date = format.parse(join_date); } catch (ParseException e) { e.printStackTrace(); } GregorianCalendar calender = new GregorianCalendar(); calender.setTime(alarm_date); calender.add(Calendar.DATE, 1); calender.add

How to repeat an action every day in an Android app?

冷暖自知 提交于 2019-12-07 21:37:34
问题 I want to repeat an action every day; it must continue working even if the app is not running or the device has been restarted (rebooted). In my code I'm trying to show a TOAST message every 1 minute (as a test); it's working fine in the emulator but on a real device it doesn't work( i tried to do some changes to fixed as i see in some answers but still the same thing) MyReceiver class MyReceiver : BroadcastReceiver() { private val channelId = "com.medanis.hikamwahimam" override fun onReceive

Alarm manager not triggering alarms at exact time in android

人盡茶涼 提交于 2019-12-07 07:40:07
问题 I scheduled alarm using Calendar class as below Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY,1); cal.getTimeInMillis(); cal.set(Calendar.MINUTE,05); long TriggerMillis = cal.getTimeInMillis(); AlarmManager aManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); aManager.set(AlarmManager.RTC_WAKEUP, TriggerMillis,pIntent); where pIntent is an pending intent to proceed further when alarm triggers. The event triggers with few seconds delay. Is that any

What happens to the alarms set via alarm manager by an app, if the app is uninstalled

你离开我真会死。 提交于 2019-12-07 00:04:36
问题 I have the below code to set up an alarm from my app. Intent intent = new Intent("MY_ALARM_NOTIFICATION"); intent.setClass(myActivity.this, OnAlarmReceive.class); intent.putExtra("id", id); PendingIntent pendingIntent = PendingIntent.getBroadcast( myActivity.this, Integer.parseInt(id), intent, PendingIntent.FLAG_UPDATE_CURRENT); Calendar timeCal = Calendar.getInstance(); timeCal.set(Calendar.HOUR_OF_DAY, hour); timeCal.set(Calendar.MINUTE, minutes); timeCal.set(Calendar.DAY_OF_MONTH, day);

Android repeat alarm manager in not triggering immediately

非 Y 不嫁゛ 提交于 2019-12-06 17:26:39
My code: Calendar calSet = Calendar.getInstance(); calSet.set(Calendar.HOUR_OF_DAY, 11); calSet.set(Calendar.MINUTE, 20); calSet.set(Calendar.SECOND, 0); calSet.set(Calendar.MILLISECOND, 0); PendingIntent pi=PendingIntent.getBroadcast(context,0,myIntent,PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP,calSet.getTimeInMillis(),pi); and say, I'm executing at 11:30. Alarm triggers immediately (which is expected). But, for the same when I use alarmManager.setRepeating(AlarmManager

Alarm everyday at 5AM morning

送分小仙女□ 提交于 2019-12-06 16:24:24
问题 I am working on an android application where I need to trigger an alarm every morning at 5 am. I have already used the concept of Intent (below is the code) and putting AlarmManager in the Service . But I didnt get the problem solution from both implementations. I am just looking for a perfect solution for this. If I add a reminder to the calendar for 1 month once the application is opened for the first time I guess that might work. But if there is any better solution for this, then please

How to repeat an action every day in an Android app?

强颜欢笑 提交于 2019-12-06 11:04:25
I want to repeat an action every day; it must continue working even if the app is not running or the device has been restarted (rebooted). In my code I'm trying to show a TOAST message every 1 minute (as a test); it's working fine in the emulator but on a real device it doesn't work( i tried to do some changes to fixed as i see in some answers but still the same thing) MyReceiver class MyReceiver : BroadcastReceiver() { private val channelId = "com.medanis.hikamwahimam" override fun onReceive(context: Context, intent: Intent) { Log.i("TAG","/////////////////// SHOW NOTIFICATION NOW ///////////

Android alarms cancelled when application is killed

孤街浪徒 提交于 2019-12-06 03:33:29
问题 I have an Android application that has a service that runs in the background, communicates with a remote server and displays notifications to users if needed. The app also has an activity for users to interact with. One of the requirements is that the application needs to start itself automatically in the morning. At the end of the day the user is free to quit the app (Quit functionality stops the service, releases the wake lock, and lets Android kill the process). In order to automatically

How to update an app widget on midnight?

倖福魔咒の 提交于 2019-12-06 01:21:50
问题 My app has a widget that shows today's date and need to be updated on midnight. The widget is defined in the manifest as <manifest> ... <application> ... <receiver android:name=".MyWidgetProviderClass" android:label="MyLabel" > <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_icon_info" /> </receiver> </application> </manifest> And the widget info file is