alarmmanager

AlarmManager repeating alarm missing randomly when phone is not in use

帅比萌擦擦* 提交于 2019-12-03 02:39:46
I am calling a background Service at interval of 30 min to read the latitude/longitude of current location and sending it to server by POST API . I am using setRepeating() method of AlarmManager class to schedule alarm every 30 minutes. But some times the alarm is getting missed and service is not called. To monitor if alarm gets called or not in every 30 min I have generated Log.txt file in the sdcard. For every time alarm called the entry for the current time will be written in the Log.txt file. But after comparing 4 to 5 devices Log.txt files I noticed that for some of devices alarm is not

How to 'restart' an android application programmatically [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: This question already has an answer here: Force application to restart on first activity 10 answers Reboot the phone on a button click 3 answers I'm trying to create a 'log out' function within my application. Basically, by logging out, the application data should be cleared. What I would like to do is after logging out, the application should restart so that credentials etc. can be entered again. The problem I'm having is that at the point of the user clicking 'log-out', the application already has 3-4 activities running, and I'm

Whiсh function is called when application is removed from task manager

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to make status of user offline. When I press home button onStop() is called, that's fine. When I press back button onDestroy() is invoked. But when I close the app from recent apps by swiping it, onStop() or onDestroy() isn't called. I need to know when the app is closed from recent apps to do something (e.g make user offline). 回答1: Make a service : public class MyService extends Service { private DefaultBinder mBinder; private AlarmManager alarmManager ; private PendingIntent alarmIntent; private void setAlarmIntent(PendingIntent

Updating app widget using AlarmManager

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to update a Widget more frequently than the 30 minute restriction imposed by the 1.6docs. After reading nearly every post in SO, and the developer docs, and various other sources, I thought I had got to a point where i could implement it. And so, I tried, and failed. Since then, I have trawled yet more forums and solutions, and I cannot seem to get it to update. I have an Update class that sets the AlarmManager: public class Update extends Service{ @Override public void onStart(Intent intent, int startId) { String currentTemp =

LocalNotification with AlarmManager and BroadcastReceiver not firing up in Android O (oreo)

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Hello I've got my local notifications running on androids prior to SDK 26 But in a Android O I've got the following warning, and the broadcast receiver is not fired. W / BroadcastQueue : Background execution not allowed : receiving Intent { act = package . name . action . LOCAL_NOTIFICATION cat =[ com . category . LocalNotification ] flg = 0x14 ( has extras ) } to package . name / com . category . localnotifications . LocalNotificationReceiver From what I've read broadcast receivers are more restricted in android O, but if so, how

Android AlarmManager.setExactAndAllowWhileIdle() and WakefulBroadcastReceiver Not working in some new manufactured and low price devices

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I think this question is asked many time in stackoverflow but still so many people struggling to resolved it. In my android app I have to wake up device for every half hour to getting current location and send it to server. For this I have used AlarmManager with setExactAndAllowWhileIdle() method and WakefulBroadcastReceiver . Its working fine in almost all standard/popular devices like samsung, LG(Nexus), Sony, Panasonic, lenovo, Motorola, Micro max and so on....But some other devices mostly china devices not supporting or cannot allow

AlarmManager from service

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i have a background Service which starts and AlaramManager. i've logged when the AlarmManager fires and see that it only fires when the application has no activities running and the only thing that runs is the background Service.. why is that ? @Override public int onStartCommand(Intent intent, int flags, int startId) { if (app.isApplicationInitilized()) { //stopAlarmManager(); server.start(); startAlarmManager(); } return START_NOT_STICKY; } public void startAlarmManager() { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System

Alarm Manager issue in Android 6.0 Doze mode

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've made an app that always worked until Android 6.0. I think it's the Doze feature that it's not allowing my Alarm to fire. I use sharedpreferences to handle the options: //ENABLE NIGHT MODE TIMER int sHour = blockerTimerPreferences.getInt("sHour", 00); int sMinute = blockerTimerPreferences.getInt("sMinute", 00); Calendar sTime = Calendar.getInstance(); sTime.set(Calendar.HOUR_OF_DAY, sHour); sTime.set(Calendar.MINUTE, sMinute); Intent enableTimer = new Intent(context, CallReceiver.class); enableTimer.putExtra("activate", true);

AlarmManager - How to repeat an alarm at the top of every hour?

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want for an event to fire every hour (at 5:00, 6:00, 7:00, etc...). I tried with a persistent background service with a thread but it wasn't the right solution because of: battery consumption service termination, due to android memory management So I'm trying with AlarmManager. It works if I set an alarm to fire in X seconds (using "set" method). But how can I repeat an event (using "setRepeating" method) at the top of every hour, until the alarm is canceled? Thanks! 回答1: When you set alarms you have two times: First trigger time

Set Repeat days of week alarm in android

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Can somebody give good logic for set repeat days of week alarm? I have done weekly Alarm by using alarmCalendar.set(Calendar.HOUR, AlarmHrsInInt); alarmCalendar.set(Calendar.MINUTE, AlarmMinsInInt); alarmCalendar.set(Calendar.SECOND, 0); alarmCalendar.set(Calendar.AM_PM, amorpm); Long alarmTime = alarmCalendar.getTimeInMillis(); Intent intent = new Intent(Alarm.this, AlarmReciever.class); intent.putExtra("keyValue", key); PendingIntent pi = PendingIntent.getBroadcast(Alarm.this, key, intent, PendingIntent.FLAG_UPDATE_CURRENT); am