repeatingalarm

Inquiry related to AlarmManager and WakeLocks

不问归期 提交于 2019-12-11 06:53:43
问题 I am developing a native android app that run a backup operation every 30 mins. I am using AlarmManager for this purpose and it works fine. Here is the code I am using to start the alarm: public static void startSync(Context context) { alarmIntent = new Intent(context, AlarmReceiver.class); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // int interval = 3600000; int interval =30000 ; manager

How to reset alarm after reboot Android Studio

自古美人都是妖i 提交于 2019-12-10 22:19:24
问题 I'm making an Alarm app which opens an activity based on time picked by User. Everything's working perfectly fine but alarm gets reset by reboot. I made an ON BOOT RECEIVER which works but I want to restart the Alarm only if the user wants it to go. I tried to use .putExtra to send data to ON BOOT broadcast but that data gets reset after reboot. I tried to set conditions using SharedPreference in broadcast but I'm stuck on how to use it. MainActivity public class MainActivity extends

AlarmManager firing alarm past the time it was set on the same day, setRepeating

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 13:04:09
问题 So basically I have this code, time returns 24hour time and repeats the alarm daily. public setAlarm(String time, Context context){ String[] strTime; strTime = time.split(":"); int hour, min, sec; //set when to alarm hour = Integer.valueOf(strTime[0]); min = Integer.valueOf(strTime[1]); sec = 0; Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, min); cal.set(Calendar.SECOND, sec); //Create a new PendingIntent and add it to the AlarmManager

Repeating notification

浪尽此生 提交于 2019-12-10 12:08:25
问题 I'm trying to set a notification that is repeated each day at a fixed hour. I'm able to set a notification by clicking on an item in a list (but that's not really interesting...) I've tried several things but I still can't make it appear automatically nor daily... Here is what I've done so far: public class main extends Activity implements PersonneAdapterListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

Android BatteryManager Returns only 1

给你一囗甜甜゛ 提交于 2019-12-07 17:55:44
问题 I am attempting to read the state of the Android battery when my repeating alarm broadcaster is called I have the following setup: public class RepeatingAlarm extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // Acquire the make of the device final String PhoneModel = android.os.Build.MODEL; final String AndroidVersion = android.os.Build.VERSION.RELEASE; // Grab the battery information int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);

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

What's Wrong with my notification code?

烂漫一生 提交于 2019-12-06 14:23:38
问题 Note: there is an update below. I've asked in the previous question about specifying a minute for an hourly repeat interval. However, I had two answers asking me to try the date component, and I did. Here it is: [[UIApplication sharedApplication] cancelAllLocalNotifications]; NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar] ; NSDateComponents *componentsForReferenceDate = [[NSDateComponents alloc] init]; [componentsForReferenceDate setHour:hour]; [componentsForReferenceDate

set alarm notification between two specific date with particular day in android

≯℡__Kan透↙ 提交于 2019-12-06 13:08:53
问题 Hello friends i want to set notification with two specific dates like date1= 2014/10/30 date2=2015/10/30 and alarm should be notify at every 5th day(means date=5) of every month until date2 . how can i achieve this any idea Thanks in advances? 来源: https://stackoverflow.com/questions/26667762/set-alarm-notification-between-two-specific-date-with-particular-day-in-android

Android BatteryManager Returns only 1

a 夏天 提交于 2019-12-06 01:40:15
I am attempting to read the state of the Android battery when my repeating alarm broadcaster is called I have the following setup: public class RepeatingAlarm extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // Acquire the make of the device final String PhoneModel = android.os.Build.MODEL; final String AndroidVersion = android.os.Build.VERSION.RELEASE; // Grab the battery information int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); final float batteryPct = level / (float

Repeating Alarm not working

半腔热情 提交于 2019-12-05 14:28:53
I know this type of questions are aksed so many times...but please first read my question before down voting or marking as duplicate. I have referred so many SO questions like this for managing alarm but cant find any solution so i am here. In my app i want to trigger repeating alarm one at daily 8.00 am and others as user specified. First i tired to repeat alarm using setRepeating...this is my code Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); calendar.set(Calendar.HOUR_OF_DAY, 8); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set