alarmmanager

Android AlarmManager or Service?

你说的曾经没有我的故事 提交于 2019-12-12 04:45:43
问题 I have an application, that has a main.java file that sets up an alarm to call a recurring service. However when I close the application the service is no longer called for some weird reason. So I was reading around what I should be doing for my application (basically what I want is something like Twicca, where the twitter app continues to run even if you close it from your "task manager"). And it looks like what I need to do is deploy my entire application as a service, so that it will keep

No sound when the Activity starts from Lock Screen

自古美人都是妖i 提交于 2019-12-12 04:43:08
问题 This seems to be a strange issue. I am using AlarmManager to set a alarm with custom audio track. The activity start and plays the music normally, but when i lock the phone the activity starts but the audio is not playing. Here is the code that i am using it. The onCreate Method PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakelock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP,"My Wake Log"); mWakelock.acquire(); this

How to set app to trigger service/alarm at a specific time every day?

只谈情不闲聊 提交于 2019-12-12 04:27:13
问题 So I want my app to send a notification at 8:00 a.m. everyday subjected to whether there is an event on that day or not. I have a SQLlite DB which stores the dates on which notification is to be sent. What I want from my app, is this- Everyday at 8 in the morning, it should check if there is an event for today. And if there is an event for that day, then send a notification. I have already implemented the part with the DB and the notification. I just need to implement the part where the app

Android: Placing a random item from a String Array in to Notifications

混江龙づ霸主 提交于 2019-12-12 03:58:21
问题 I want my app to be able to pick a random item from this string array: <string-array name="quote_list"> <item>Quote 1 </item> <item>Quote 2 </item> <item>Quote 3</item> </string-array> And send the item off in a notification to the user. (Will be at a time chosen by user, using alarmmanager) I believe I can generate a random item using the following method. How to get a random value from a string array in android? Would I start off with something like this? NotificationCompat.Builder mBuilder

Can not create Alarm Manager

半世苍凉 提交于 2019-12-12 03:38:51
问题 Sorry for my bad English. I faced with the problem. I try to create persistent alarm notification. Alarm notification must start every 10 seconds. I am using Alarm Manager,but it doest't work. What i am doing wrong? public class RemindReceiver extends BroadcastReceiver { private Class<?> activityClass; public RemindReceiver() { } public RemindReceiver(Class<?> activityClass) { this.activityClass = activityClass; } @Override public void onReceive(Context context, Intent intent) {

How to get the position of toggle button clicked within listview?

两盒软妹~` 提交于 2019-12-12 03:27:31
问题 I have a listview that contains alarm times and a toggle button to turn off/on that alarm. When I click the toggle buttons for the specific listview, I would like to set/cancel that specific alarm. But how do I get the position of the listview I clicked on based on the view? When I click my toggle button on/off it hits this code: public void enableAlarm(View view) { // set/cancel alarm manager pending intent } I have some information stored for each particular listview item in a Database, but

Set alarm for 1 min but it called after 5 minutes

痞子三分冷 提交于 2019-12-12 03:09:47
问题 I have set alarm for 1 minutes but it called after every 5 minutes. AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(getActivity(), MyBroadcastReceiver.class); intent.setAction("com.example"); PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); //pending intent alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, new Date().getTime(), 60000,

AlarmManager.RTC doing too many updates on wakeup

ⅰ亾dé卋堺 提交于 2019-12-12 03:09:15
问题 I've got a service that I run every 30 minutes via AlarmManager.RTC . If the device is asleep long enough for the service to be called twice (and thus have both of them be rescsheduled), when it wakes up, it fires off the service twice at once. The desired behavior is for the AlarmManager to just fire off one Intent when it wakes up. How can I accomplish this? 回答1: Try this: PendingIntent.FLAG_UPDATE_CURRENT 回答2: Have you cancel the old one of Alarm Manager. If no means, just cancel the old

AlarmManager don't run as expectly

流过昼夜 提交于 2019-12-12 03:03:04
问题 As you suggested me to use AlarmManager instead of Timer, I thought, the program will run. But unfortunately, it does not. Or, better, not always... This is my code: long millis = 0; this.alarmMgr = (AlarmManager)this.main.getSystemService(Context.ALARM_SERVICE); this.checkPendingIntent = PendingIntent.getBroadcast(this.main, 0, new Intent(this.main, AlarmReceiver.class), 0); if(frequency.compareTo("1HOUR") == 0) millis = 3600 * 1000; if(frequency.compareTo("12HOUR") == 0) millis = 12 * 3600

AlarmManager doesn't work on samsung device with Android lollipop 5.0.2

流过昼夜 提交于 2019-12-12 02:57:39
问题 I have an issue with the AlarmManager API, it doesn't fire at all on my samsung device, but it works on other Android device... My code is like that: public void setAlarm(int hourAlarm, int minutesAlarm, int numeroAlarm, boolean yesOrNoRepeatAlarm) { PendingIntent pendingIntent = PendingIntent.getBroadcast(this, numeroAlarm, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT); Log.i("numeroAlarm", numeroAlarm + ""); Calendar calendar = Calendar.getInstance(); if( (calendar.get(Calendar.HOUR