alarmmanager

how to set alarm to repeat monthly

拟墨画扇 提交于 2019-12-05 17:39:50
Currently I am working on an application to set reminders on monthly basis. I am not able to provide the correct repeating interval for my alarmmanager. Pls provide info about the same. this is my code, but this will not raise alarm for Feb or months having 30 days. Also pls provide code to set yearly repeating alaram. repeatTime=(AlarmManager.INTERVAL_DAY*31); mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, when.getTimeInMillis(), repeatTime, pi); Thanks, Sharath this is how you calculate interval between today in extacly one month after, use this logic to reset alarm

Start activity when screen is off

蓝咒 提交于 2019-12-05 15:07:09
I have set up an AlarmManager to start up an activity. This activity also plays a sound, similar to an alarm app or an incoming call. It works ok if the screen is on, even if the screen is locked. If the screen is off, it doesn't work at all. I tried using the following as the first thing in onCreate getWindow().setFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON, WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); If the screenlock is not enabled, this turns on the screen and I can see my activity closing. I can't hear the sound playing. If the screenlock is enabled, the screen won't turn on

android alarm manager stops after few hours

大城市里の小女人 提交于 2019-12-05 14:22:05
I have create an alarm manager that start a service every 5 second, the app is running well but after few hours the alarm manager stop running. Note that the application is not used by the user which mean that it is running on background without user interaction. Does any one knows how to start a service every some second without stopping ? AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class); intent.putExtra(ONE_TIME, Boolean.TRUE); PendingIntent pi = PendingIntent.getBroadcast(context, 0,

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

笑着哭i 提交于 2019-12-05 09:14:10
问题 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? 回答1: Falmarri's answer is the correct one, and I do not understand your concerns. In onPostExecute() , when you determine that things went awry

AlarmManager object after turning off and on the phone

ぃ、小莉子 提交于 2019-12-05 08:57:49
In my app, I set an alarm AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); ... PendingIntent pendingIntent = PendingIntent.getBroadcast(context, id, intent, PendingIntent.FLAG_UPDATE_CURRENT); ... alarmMgr.set(AlarmManager.RTC_WAKEUP, time.getTimeInMillis(), pendingIntent); It works fine unless I turn off and turn on the phone. To be more specific, let's say at 10:20, I set an alarm to 10:22 and I turn off and turn on the phone at 10:21, alarm won't work. What might be the problem? Is that a broadcast issue of the pendingIntent there or should I set some

Alarm Manager not working at specific given time interval

寵の児 提交于 2019-12-05 08:28:15
Hi I am using alarm Manager for specific time interval for 3 minutes and I started monitoring. It worked for sometimes and suddenly I noticed there is irregular time interval which is not correct! You can see in attached log where at "20-Jul-2016 12:22:03 pm" time varies! I connected the phone and turned off the screen and monitored! where for every 3 minutes, i hit the server and gets the response as 1. But at one time, it takes 5 minutes to hit the server! Why this strange issue happened? Here is code. public void startAt3() { Intent alarmIntent = new Intent(ActivityTracking.this,

Android Background Service vs AlarmManager

依然范特西╮ 提交于 2019-12-05 08:24:19
Can someone give a little bit briefing or perhaps more elaborate details on differences Android background service with Alarm Manager? How they differ? And in which situation I should use each? I am developing an application that need to download data from Web Service at periodic time. The application has few modules and each modules has different interval time period to download / sync the data to Web Service. Let say + Module A need to sync in every 15 mins + Module B need to sync in every 1 hour + Module C need to sync in every day + Module D need to sync weekly + Module E need to sync

Android Studio stack=java.lang.NoClassDefFoundError: Failed resolution of: Landroid/icu/util/Calendar;

安稳与你 提交于 2019-12-05 06:34:13
sorry my english is not very good but. i use the calendar class for a alarm app with the alarm manager, but i have a error with the instance of the class calendar. i investiged in other forums but i not find poblem what is. please i need your help. the error is marked in the instance of the calendar class enter image description here As far as i can see, you could just use the normal Calendar instead of the in API 24 introduced ICU Calendar . Try to use this import java.util.Calendar instead of this import android.icu.util.Calendar . From Calendar pick date: import java.util.Calendar instead

Notification at specific time

。_饼干妹妹 提交于 2019-12-05 03:36:52
I have a notification at a specific time, see my code: //Create alarm manager AlarmManager alarmMgr0 = (AlarmManager)getSystemService(Context.ALARM_SERVICE); //Create pending intent & register it to your alarm notifier class Intent intent0 = new Intent(this, AlarmReceiver_maandag_1e.class); intent0.putExtra("uur", "1e"); PendingIntent pendingIntent0 = PendingIntent.getBroadcast(this, 0, intent0, 0); //set timer you want alarm to work (here I have set it to 8.30) Calendar timeOff9 = Calendar.getInstance(); timeOff9.set(Calendar.HOUR_OF_DAY, 8); timeOff9.set(Calendar.MINUTE, 30); timeOff9.set

How to run an android function every 15 minutes , and specifically on the 15 minute mark everyday?

怎甘沉沦 提交于 2019-12-05 03:28:57
This maybe a repeated question here but I'm still facing issues on this, hope there's a solution around. Thanks in advance. How do I set the alarm manager to run so as to execute the function specifically at every 15 minutes clock interval, for example 8:00, 8:15, 8:30, 8:45, 9:00 everyday regardless of the time when the application is started. Take an example if let's say I started my application main activity at 7:47, and I would like the alarm to start at 8:00, followed along with 8:15, 8:30 and etc....how should I do? I would really appreciate if any suggestions are given.. you should