alarm

How to handle Alarm notification in Android?

喜你入骨 提交于 2019-11-27 03:38:15
问题 I'm developing an media player application for Android, for which I need to handle any Alarm notification, and based on that I'll pause my playback. When the Alarm in snoozed or dismissed, I'll then resume the playback. I googled a lot for the Alarm handling, but what I found was the way to enable Alarm notifications through code, set the intent and then handle it. However, no where could I locate just handling the Alarm notification part. I don't need to set the Alarm on, it could've been

How to detect alarm ringing or other apps using speaker? [closed]

左心房为你撑大大i 提交于 2019-11-27 02:58:20
问题 I am developing a music app. I want to detect that other apps using speaker or alarm ringing for play/pause music. For phone call i use PhoneStateListener. I tryed OnAudioFocusChangeListener for to detect other audios. But didn't work. I wondering how to solve this problem. 回答1: I solved my problem for default alarm application: public static final String ALARM_ALERT_ACTION = "com.android.deskclock.ALARM_ALERT"; public static final String ALARM_SNOOZE_ACTION = "com.android.deskclock.ALARM

How can I interact with the Lockscreen layout to display text into it, like this app:

妖精的绣舞 提交于 2019-11-27 02:51:55
问题 I just discovered this application : https://market.android.com/details?id=de.j4velin.lockscreenCalendar It seem that is now possible to write some text inside the lockscreen in the place where the alarm is usually written. I would like to display custom text on this place, but have totally no idea on how to achieve that. This guy succeed to write calendar events at this place. Thank a lot for any clue//snippet that would help me. 回答1: This is astonishingly easy to achieve and astonishingly

Lollipop API for controlling the Alarm icon in status bar

人走茶凉 提交于 2019-11-27 02:49:03
问题 This is a Lollipop-specific question , since the API has changed. To find out how to do this on earlier versions, see related question: Controlling the Alarm icon in status bar I would like to know how to turn on / off the system Alarm icon in the status bar as shown in this image: Timely Alarm Clock controls this icon on Lollipop as of release 1.3. Prior to that release, the code was using private APIs as detailed in the related question. The new technique they use works on an unrooted Nexus

Android: How to repeat a service with AlarmManager every 15 minutes, but only run from 8:00AM to 18:00PM?

限于喜欢 提交于 2019-11-27 00:24:10
问题 I need to check data update periodly, but the data is only updating during the daytime, so I want this repeating action run only in that time section for saving battery and bandwidth. What should I do? 回答1: If the service is talking to the cloud with HTTP get/post/whatever requests, then note that a C2DM solution would net better battery life, and that a SyncAdapter solution could provide a few benefits. (I recommend watching the Google I/O videos on both topics.) The following code does

python: windows equivalent of SIGALRM

江枫思渺然 提交于 2019-11-26 23:11:31
I have this decorator: def timed_out(timeout): def decorate(f): if not hasattr(signal, "SIGALRM"): return f def handler(signum, frame): raise TimedOutExc() @functools.wraps(f) def new_f(*args, **kwargs): old = signal.signal(signal.SIGALRM, handler) signal.alarm(timeout) try: result = f(*args, **kwargs) finally: signal.signal(signal.SIGALRM, old) signal.alarm(0) return result new_f.func_name = f.func_name return new_f return decorate The code only does anything on linux, though, as on windows, there is no SIGALRM . What would be the simplest way to have this code work in Windows as well? It's

Start app at a specific time

心不动则不痛 提交于 2019-11-26 22:04:11
I was wondering if it's possible (and if it is how) to start up my app at a specific time, something like an alarmclock which goes off at a specific time. Let's say I want my app to start up at 8 in the morning, is that feasable ? ninjasense You can do it with AlarmManager, heres a short example. First you need to set the alarm: AlarmManager am = (AlarmManager) con.getSystemService(Context.ALARM_SERVICE); Date futureDate = new Date(new Date().getTime() + 86400000); futureDate.setHours(8); futureDate.setMinutes(0); futureDate.setSeconds(0); Intent intent = new Intent(con, MyAppReciever.class);

How to automatically restart a service even if user force close it?

帅比萌擦擦* 提交于 2019-11-26 19:34:45
I want a service to run all the time in my application. So I want to restart it even if it is force closed by user. There is definitely a way to do it as apps like facebook are doing it.(Its not done using push notification, facebook restarts its service even if internet is off). Any help would be appreciated. Thanks! Mehul Joisar First of all, it is really very bad pattern to run service forcefully against the user's willingness . Anyways, you can restart it by using a BroadcastReceiver which handles the broadcast sent from onDestroy() of your service. StickyService.java public class

Android AlarmManager problem with setting & resetting an alarm

家住魔仙堡 提交于 2019-11-26 18:21:07
问题 I use an Alarm to fetch data from server. I like to give user the option to start and stop the alarm. This means I have to check and see if alarm is already set. I found some code that tells me if the alarm is already set: Intent I = new Intent(getApplicationContext(),AlarmReceiver.class); PendingIntent P = PendingIntent.getBroadcast(getApplicationContext(), 0, I, PendingIntent.FLAG_NO_CREATE); found = (P!=null); if the Alarm is already set I cancel it but if it is not set then I set it (like

signal.alarm replacement in Windows [Python]

本小妞迷上赌 提交于 2019-11-26 17:11:16
问题 I have a function that occasionally hangs. Normally I would set an alarm, but I'm in Windows and it's unavailable. Is there a simple way around this, or should I just create a thread that calls time.sleep()? Ended up going with a thread. Only trick was using os._exit instead of sys.exit import os import time import threading class Alarm (threading.Thread): def __init__ (self, timeout): threading.Thread.__init__ (self) self.timeout = timeout self.setDaemon (True) def run (self): time.sleep