alarmmanager

How to keep a task alive after phone sleeps?

青春壹個敷衍的年華 提交于 2019-12-11 07:43:18
问题 my application needs to send a message to my server every 30 seconds or so. I understand I need to use AlarmManager using RTC_WAKEUP or ELAPSED_REALTIME_WAKEUP. now I don't understand two things: 1) If the AlarmManager wakes up the device, why do I need to aquire a WakeLock? 2) I saw an example for using AlarmManager with WakeLock. In this example, its setting the alarm to send a broadcast to a broadcast receiver which then acquires a static wake lock and then start an IntentService which

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=

How to ensure AlarmManager survives phone restart and application kill

南楼画角 提交于 2019-12-11 07:27:29
问题 I have an Android application where I want to send a notification to the user at a fixed time during the day For this, I am using AlarmManager to schedule an alarm and then use that to generate notifications But I am facing issue that if the user "Force Closed" the app, the Alarms is reset and hence I don't receive any notifications. Is this is a normal behaviour? Is there is any way out for this? Also, the alarms also gets cancelled if the phone restarts. How do I control that? Do I need to

AlarmManager not adding new Alarms, or not triggering receiver

两盒软妹~` 提交于 2019-12-11 07:13:07
问题 I'm currently developing an application which makes use of Android's AlarmManager. I'm trying to add a new alarm to the AlarmManager, but after several hours of trying various things and checking various threads on SO, I'm still at a brick wall. Are there any problems with my code? Main Activity - saveAlarm() function /** * Saves the current alarm. Adds to the database if it doesn't already exist, or updates if it does. * Also sets alert with AlarmManager. */ public void saveAlarm() { //

Android, my service wont start

£可爱£侵袭症+ 提交于 2019-12-11 07:08:10
问题 I have been trying to set up a polling system that grabs data from a server one every day. So my plan is to setup AlarmManager so that it starts my service 12:00 every day and the service looks for some info on my server and displays a notification in the status bar based on the data from the server. The problem is that i can't seem to even start my service in any way. I first tried to register an PendingIntent in the AlarmManager, but my service was never started. And now I'm just trying to

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

Using AlarmManager to activate and deactivate silence mode

亡梦爱人 提交于 2019-12-11 06:13:32
问题 In my program, I am getting 2 dates from user. First date is for activating silence mode and the second date is deactivating it. For handling this issue, I have tried to use 2 different AlarmManager and 2 different BroadcastReceiver but I couldn't achieve it. I can activate silence mode at the first date but I couldn't deactivate it. This a part of my code: public class AddEvent extends AppCompatActivity { private static PendingIntent silenceActivatorPendingIntent; private static

ANDROID: is it possible to create a database and save some information in it every 100 seconds

坚强是说给别人听的谎言 提交于 2019-12-11 05:34:18
问题 I collect some information inside a Spinner and this information can change for example something may disappear or something new may come I want the application to store this information every 100 seconds in a database is it possible to do something like this? I'm thinking of creating a database and within this database storing this information but I'm not sure about this " every 100 seconds " part, how would I do this? I'm thinking that maybe I will have to create a process that will be

Is there a way to keep a repeating alarm working after existing the app that uses a broadcast receiver?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 05:29:31
问题 I am new on Android. I am trying to create an application that uses BroadcastReceiver to execute a function on the main activity triggered by a repeating alarm. I read that I had to dynamically register the broadcastReceiver which I did - this is to be able to execute the function on the main activity. The problem I am faced with is that as soon as the app is exited, the alarm stops working. I read that this is by design - is there a way to overcome this or do I have to use a service ? Thanks

Exact time for custom notifications in Android

故事扮演 提交于 2019-12-11 04:03:37
问题 I am developing an Android application for counseling services. Client can view their scheduled appointment in app. For example, Next appointment: Dec 31 2016 10:00AM Now I need to do that user will receive 2 notifications – reminders about appointment. One on 7 days before and another on 3 days before. I save this date (Dec 31 2016 10:00AM) as a String so I can extract year, month, etc. I found that I need to write some kind of service which will send these notifications. This is what I