alarmmanager

Running a repeating task in background on a real time application

[亡魂溺海] 提交于 2019-12-19 11:17:43
问题 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?

Can i use AlarmManager with LocalBroadcastManager on android?

我是研究僧i 提交于 2019-12-19 05:33:21
问题 I've got this code: private AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); private PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, new Intent("my action-name"), 0); alarmManager.setInexactRepeating((int)AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + autoUpdateIntervalInMinutes * 60 * 1000, autoUpdateIntervalInMinutes * 60 * 1000, alarmIntent); But I would like to change this for LocalBroadcastManager. Is this possible?

Send data to the alarm manager broadcast receiver

◇◆丶佛笑我妖孽 提交于 2019-12-18 19:08:31
问题 I am missing something here and I hope someone can help me out. I am setting up an alarm using the following: AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Intent broadcast_intent = new Intent(this, AlarmBroadcastReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, broadcast_intent, 0); broadcast_intent.putExtra("test", "ValueReceived"); //data to pass Date date = someVariable.getDateTime(); long triggerAtTime = date.getTime();

AlarmManager not working as expected in sleep mode on S5 Neo

試著忘記壹切 提交于 2019-12-18 15:54:33
问题 I am using an AlarmManager in a Service to be triggered every minute. PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, getUpdateServiceIntent(mContext), PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); // Cancel any pending Intent am.cancel(pendingIntent); // Set a new one am.set(AlarmManager.RTC_WAKEUP, 60000, pendingIntent); On the Samsung S5 Neo : When the screen is active, it is working as expected.

Creating A Digital Clock Widget With A Custom Font

流过昼夜 提交于 2019-12-18 14:57:21
问题 I'm trying to create a digital clock widget with a custom font. And this has proven to be the biggest challenge of my Android experience. (Thought it would be as simple as tc.setTypeFace("whatever") and be done with it) The best way seems to be scratch the TextClock and use an ImageView and pass a Bitmap to it using a custom AlarmManager to create a new image for the view each second. Before I get into the Bitmap generation, I practiced on a simple TextView using this tutorial Alarm Manager

setRepeating() of AlarmManager repeats after 1 minute no matter what the time is set (5 seconds in this case, API 18+)

不羁的心 提交于 2019-12-18 14:47:17
问题 I have set the repeat time to 5 seconds. The first toast appears after 5 seconds, but all the next once repeat after 1 minute. I tried the code with setRepeating() as well, it still doesn't work. here is my code: public void constructJob(){ Intent alertIntent = new Intent(this, AlarmManagerService.class); PendingIntent pendingIntent = PendingIntent.getBroadcast( this, 0, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM

Android: can Android AlarmManager wake up the device to perform the scheduled task?

限于喜欢 提交于 2019-12-18 12:43:19
问题 I need to make an App that set up a calendar for the week, basically the user will input the start hour and finish hour of the activity for the every day of the week. He will do only once. After that set up, the application (I will use AlarmManager ) will start his activity (continuously play video) at the set hour and finish and the set hour: Every day of the week; forever, without human interaction (of course the phone/tablet must be switched on and plugged to electricity). My concern is

How to protect background service/alarms to be kill in newly launched devices in customized OS like oppo - coloros, vivo-funtouch os, Xiomi-MIUI os?

穿精又带淫゛_ 提交于 2019-12-18 12:16:46
问题 I have a WakefulBroadcastReceiver with IntentService , every half hour alarm called and doing some stuff. I have already handle doze mode with setExactAndAllowWhileIdle() method. Some new smart phones with customized os recently launched in market they have their own customized os based on android os. Like oppo with color os, vivo with funtouch os, xiomi with MIUI os. In the OSs there is a feature to clear memory. They have one touch clear memory option. for example if user clear recent app

How to check if Pending intent triggered by AlarmManager setRepeating is already running?

一个人想着一个人 提交于 2019-12-18 11:56:55
问题 I would be glad to know how to check if Pending intent which is triggered by an Alarm Manager which starts an activity at a specific time given by AlarmManager.setRepeating? To be more specific , I have an activity which kicks off another activity with a paticular set time, or repeating time, (which works) . But i want to know if the request was already set by the user? in that case i should not start certain values. This is how i start the scheduled activity. Intent myIntent = new Intent

Alarm “cancel” button not working correctly

做~自己de王妃 提交于 2019-12-18 09:36:29
问题 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