android-alarms

AlarmManager not working properly

筅森魡賤 提交于 2019-11-30 04:48:11
问题 I'm trying to create an alarm based application. I'm using AlarmManager . The thing is that it's not reliable at all. In some devices it works.. in other devices it works somethimes.. and in other devices it doesn't work at all. When I say that it doesn't work is that simply, alarms won't fire. For example, in my Xiaomi Mi4, if you turn off the screen, no alarm will fire. I have a testing Moto G and in that phone alarms use to work fine, but in OnePlus, alarms won't fire too. They simply are

Android P Beta - AlarmManager Notifications not working

喜欢而已 提交于 2019-11-29 19:49:36
问题 I'm testing my application on Android P beta release 4. My app's targetSdkVersion is 27 It has been observed that alarm manager notifications are not working as expected. I'm using below code to set the notifications - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, AlarmIntentBuilder.buildPendingIntent(context, uri)); } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK

AlarmManager when the phone is turned off - ANDROID

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 19:43:29
问题 I'm doing an alarm System but i've a problem when the phone is turned off.. The alarm doesn't work.. I'm setting de alarm as follows: public void doIntents(Context context, long milis, Tratam trat){ cal=Calendar.getInstance(); alarmManager = (AlarmManager) context.getSystemService(Service.ALARM_SERVICE); cal.setTimeInMillis(milis); Intent intent = new Intent(context, OnAlarmReceiver.class); pendingIntent = PendingIntent.getBroadcast(context, trat.getId(), intent, PendingIntent.FLAG_UPDATE

How to get the number of alarms in Android phone?

筅森魡賤 提交于 2019-11-29 17:47:46
I am trying to use the following code to get the number of alarms currently set on the phone. Uri uri = Uri.parse("content://com.android.deskclock/AlarmClock"); Cursor c = getApplicationContext().getContentResolver().query(uri, null, null, null,null); But I get a NullPointerException when I try to fetch the number using int num = c.getCount(); System.out.println("No of alarms : "+c.getCount()); Please let me know what I am doing wrong ? The exception occurs in getCount() itself so I am not able to display the number of alarms. EDIT: I also get this message on my LogCat : ActivityThread(13290):

Alarm “cancel” button not working correctly

梦想与她 提交于 2019-11-29 16:33:55
I have 2 buttons save and set alarm and cancel alarm which are meant to do exactly what they suggest. Inside onCreate declared variables final Intent alarmintent = new Intent(AlarmActivity.this, AlarmReceiver.class); final AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); final PendingIntent sender1 = PendingIntent.getBroadcast(getApplicationContext(), 2, alarmintent, PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA); Code inside Cancel Button onClickListener boolean alarmUp = (PendingIntent.getBroadcast(AlarmActivity.this, 2,alarmintent,PendingIntent

Alarm manager don't work after some time

∥☆過路亽.° 提交于 2019-11-29 12:50:09
This is my code. It works correctly, but after some time (about 1 hour) it doesn't work. Whats wrong? Thanks in advance. <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> public class Alarm extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context, "Alarm !!!!!!!!!!!!!", Toast.LENGTH_LONG).show(); } public void SetAlarm(Context context) { AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, Alarm.class); PendingIntent pi = PendingIntent

Repeating Alarm for specific days of week android

大憨熊 提交于 2019-11-29 09:50:04
问题 In my application I have a functionality to trigger alarm in 4 senerios: Only once for a user chosen date and time Daily for chosen time Weekly according to chosen date and time User chosen custom days of the week I successfully implement the first 3 senerios by using the follow: Only once: Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, Integer.parseInt(date[0])); calendar.set(Calendar.MONTH, (Integer.parseInt(date[1])) - 1); calendar.set(Calendar.DAY_OF_MONTH,

Android start running JobScheduler at specific time

浪子不回头ぞ 提交于 2019-11-29 09:26:22
问题 I want to start a JobScheduler at a specific time everyday , and finish it after 3 hours. I have the part of triggering the job every 20 min, and for 3 hours, but in JobInfo.Builder class there's no option for starting the job at an exact time. Going over the JobInfo.Builder class overview, there's nothing there that sets the time for starting a JobScheduler. Obviously, i don't want to run it for the whole day, and check that the time matches, this will drain more battery than needed, and is

Identify and cancel an alarm send to an AlarmManager

懵懂的女人 提交于 2019-11-29 09:07:32
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? 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-29 07:44:32
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.SECOND, 0); calNow.set(Calendar.MILLISECOND, 0); } else if(in_Date==2) { calNow.set(Calendar.HOUR_OF