alarmmanager

Repeating Alarm in Android

折月煮酒 提交于 2019-12-24 14:56:11
问题 What is the best way to implement repeating alarm in my android application? Every user selects a specific time and I want to notify them when this time approaches on daily bases. I have come across this, but I am wondering whether this is the best way? 回答1: The alarm manager should meet your needs. There is no better way except for maybe having a server ping your client. Since android really doesn't like things that repeat on a predictable interval, and since recent versions don't let you

AlarmMenager Checking if alarm already fired

非 Y 不嫁゛ 提交于 2019-12-24 14:43:01
问题 I developed an Alarm clock. A main screen witch lists all alarms and add option to add new alarm to list. I am using an Alarm Manager to fire a notification or open user screen. After user open notification screen and hit button, it returns to main screen and list all alarms. All alarms that already fired, and will not fire again, are marked with different color. To identify witch alarms are fired, I am using this code: How to check if AlarmManager already has an alarm set? But this code is

Running a repeating task in background on a real time application

久未见 提交于 2019-12-24 14:00:00
问题 I'm writing an application which is continuously listening and checking the sensors (almost all available) and saving that data into the database in the device. I need to make some calculations every X second with that data and throw a new event if the calculations check says so. I'm thinking about requesting to have the device plugged in while using the application (regarding battery drain). What's the best approach for the task that needs to make the calculations and throw the event? Timer?

alarmManager not properly set after restart

余生颓废 提交于 2019-12-24 11:53:49
问题 I want to get a notification every day (at 13:00) with alarmManager , but when the device is restarted, the alarm is active for one day only and does not work for 2nd or 3rd day unless I run my application. Why does it run only once? MainActivity.class: public class MainActivity extends ActionBarActivity implements OnClickListener { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); alarmKurulum(); } public void alarmKurulum() { Intent alarmIntent = new Intent

How to keep service alive when remove app from stack

丶灬走出姿态 提交于 2019-12-24 10:58:05
问题 I want to show notification every minute using Alarm Manager, I have implemented below code, it's working fine but the problem is when I remove app from stack the service is not running. I want keep alive, I have tried START_STICKY in onStartCommand and also used onTaskRemoved but it's same. I also tried to implement using WakefulIntentService but the problem is same. My code is below. In MainActivity Intent myIntent = new Intent(NotificationDemo.this, MyReceiver.class); myIntent.putExtra(

Unable to set proper Context to cancel alarmmanager

怎甘沉沦 提交于 2019-12-24 07:31:21
问题 I have created an alarm with a notification and a button to stop the alarm but it seems that there is some issue with the Context that I have to get in order to cancel the AlarmManager . I have researched a lot and I think I have applied most of the things I found but somehow can't get this to work. I am aware the PendingIntent has to be the same and it appears to me they are with the same request codes too. AlarmSlave.class - Sets Alarm public class AlarmSlave /*extends Service*/ { private

Alarm not accessing BroadcastReceiver

会有一股神秘感。 提交于 2019-12-24 07:25:50
问题 I've got a timepicker to set the alarm public class TimePickerFragment : DialogFragment, TimePickerDialog.IOnTimeSetListener { public static readonly string TAG = "MyTimePickerFragment"; Action<DateTime> timeSelectedHandler = delegate { }; public static TimePickerFragment NewInstance(Action<DateTime> onTimeSelected) { TimePickerFragment frag = new TimePickerFragment(); frag.timeSelectedHandler = onTimeSelected; return frag; } public override Dialog OnCreateDialog(Bundle savedInstanceState) {

How to stop alarm from executing after PendingIntent has been received - Android

那年仲夏 提交于 2019-12-24 04:13:01
问题 Before closing this issue or marking as duplicate based on the title, it is different from the regular "cancel alarm using AlarmManager and PendingIntent" questions. I am capable of creating and cancelling pending intents, as long as they are set for a time in the future and haven't gone off yet. I'm testing this using the following terminal command to view the PendingIntent s before creating an alarm as well as after: adb shell dumpsys alarm Here is my code for scheduling alarms in my custom

How to stop alarm from executing after PendingIntent has been received - Android

左心房为你撑大大i 提交于 2019-12-24 04:12:22
问题 Before closing this issue or marking as duplicate based on the title, it is different from the regular "cancel alarm using AlarmManager and PendingIntent" questions. I am capable of creating and cancelling pending intents, as long as they are set for a time in the future and haven't gone off yet. I'm testing this using the following terminal command to view the PendingIntent s before creating an alarm as well as after: adb shell dumpsys alarm Here is my code for scheduling alarms in my custom

NullPointerException while fetching current GPS

左心房为你撑大大i 提交于 2019-12-24 02:42:55
问题 I have a test screen where there is a button - where it is pressed it calls the service. I'm trying to implement a way to get the current gps location of the current user and it is crashing when it tries to call. Can anyone tell what the problem is? package com.example.whereyouapp; import java.util.Arrays; import android.app.AlarmManager; import android.app.PendingIntent; import android.app.Service; import android.content.ContentValues; import android.content.Context; import android.content