android-alarms

Cannot figure out how to create the cancel button for ringing alarm

我只是一个虾纸丫 提交于 2019-12-11 17:57:58
问题 I am having trouble to stop the alarm from ringing even after I have pressed the stopAlarm button. I cannot figure out how to get access to the same Ringtone instance and call stop(). This is my start alarm switch in MainActivity java class. public void switchClicked(View view) { if (((Switch) view).isChecked()) { Log.d("MainActivity", "Alarm On"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, alarmTimePicker.getHour()); calendar.set(Calendar.MINUTE,

AlarmManager on Android won't fire anything

ぐ巨炮叔叔 提交于 2019-12-11 16:45:37
问题 I'm trying to make Android fire a Alarm at a certain time the user specifies to check if the user has posted to the service. However, Android won't fire the intent. AndroidManifest.xml: <receiver android:name="me.kennydude.dailybooth.NoBoothNotify.AlarmReciever" /> <service android:name="me.kennydude.dailybooth.NoBoothNotify.AlarmService"> </service> NoBoothNotify.java function that sets the alarm: public static void settingsChanged(){ Context cntxt = DailyboothApplication.getInstance();

Broadcast receiver not working when app is cleared from RAM

允我心安 提交于 2019-12-11 13:32:52
问题 I am new to android. I am making an alarm clock. Its working perfectly until the user clears the app from the RAM. On searching, I found that broadcast receivers don't work if the app is cleared from the RAM. So, what exactly should I do? Will sending the broadcast from a service help? Also if you have a link to a good tutorial to Services in android, pls do share. Also let me know if there is some other way to solve my problem. 回答1: In Xiaomi devices, you just have to add your app to

AlarmManager not set or not firing on Marshmallow after certain time

只愿长相守 提交于 2019-12-11 12:58:08
问题 I have been successfully using the following construct to start an AlarmManager in some of my apps upto Android 5: Intent serviceIntent = new Intent(context, MyService.class); PendingIntent pi = PendingIntent.getService(context, alarmId, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT); DateTime inMinutes = (new DateTime()).plusMinutes(60); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, inMinutes.getMillis(), pi); But since

ANDROID - service called by AlarmManager wont stop after destroy

巧了我就是萌 提交于 2019-12-11 11:25:10
问题 i have a service getting started by Alarm Manager set to be repeated: AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); serviceSaveSample = new Intent(RunActivity.this,SaveSampleService.class); alarmSaveSample = PendingIntent.getService(getApplicationContext(), 9988766, serviceSaveSample, PendingIntent.FLAG_CANCEL_CURRENT); alarm.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (secondsToSample*1000) , secondsToSample*1000, alarmSaveSample); my

Show “left time” until the alarm start

旧城冷巷雨未停 提交于 2019-12-11 08:20:23
问题 I whould like to create a alarm (AlarmManager) in Android. The alarm must show the left time until its finish. So the user click on "set alarm at 11 pm" and see in a TextView "alarm in xy hours/minuts/seconds". How can I achieve this? Thanks. 回答1: Try like this Calendar calendar = Calendar.getInstance(); Long preTime = calendar.getTimeInMillis(); // set alarm after 5 minute calendar.add(Calendar.MINUTE, 5); Long postTime = calendar.getTimeInMillis(); Long delay = postTime - preTime;

AlarmManager - expected behaviour of alarm when device time is changed?

天涯浪子 提交于 2019-12-11 07:53:40
问题 Assume I set an alarm using the AlarmManager.set(int type, long triggerAtMillis, PendingIntent operation) method for 2pm today and the current time is 1pm. Now, if I change the time on the device to be 3pm (i.e. 3pm today or any day in the future), what should happen to my alarm? Should it trigger? 回答1: No that will not triggered by AlarmManager . So you should listen about time change actions and re-create the alarm. Those actions are Intent.ACTION_TIME_TICK Intent.ACTION_TIMEZONE_CHANGED

Use alarmManager and service to get data from server repeatedly

喜你入骨 提交于 2019-12-11 07:37:36
问题 My question is I want to verify every two hour that there is new data in the database, for that I create this user interface : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <EditText android:id="@+id/speedAlert" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:gravity="center" android:hint="km/h" android:inputType=

Android Clock App Set Alarm

梦想的初衷 提交于 2019-12-11 06:37:31
问题 I need to know if this is possible, and if it is, how I should proceed. I'd like to make an app that will create a repeating alarm within the stock Android Clock App. It should go off at 8am each morning and should only take one button to activate within my app. Thanks in advance 回答1: Try this: public void createAlarm(String message, int hour, int minutes) { Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM) .putExtra(AlarmClock.EXTRA_MESSAGE, message) .putExtra(AlarmClock.EXTRA_HOUR,

android alarm died during onReceive

我的未来我决定 提交于 2019-12-11 00:34:20
问题 i have a timer app, which wakes up the device with system alarms (RTC_WAKEUP) and opens my app. after thousands of successful alarms, it just happend, that the set alarm was not completely successful. it died during onReceive() and did not start my app, nor it fired a system notification. here is the BroadcastReceiver's onReceive() method: public void onReceive(Context context, Intent intent) { Log.i("timer", "timer's end broadcast received at: " + (System.currentTimeMillis() / 1000) ); m