How to cancel this repeating alarm?

Call cancel() on AlarmManager with an equivalent PendingIntent to the one you used with setRepeating(): Intent intent = new Intent(this, AlarmReceive.class); PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.cancel(sender);

Android get list of active alarms

No, AFAIK you can’t do that programmatically so showing that info to a user in UI is not feasible. However for your own reference you can dump the alarm data via adb shell dumpsys alarm You don’t need root permission for that. But what you get from above could be very confusing to understand. In … Read more

getExtra from Intent launched from a pendingIntent

If you change the Extra’s value in the intent, then while creating the pending intent you should use the flag PendingIntent.FLAG_CANCEL_CURRENT. A simple example would be PendingIntent pi = PendingIntent.getBroadcast(context, 0,intentWithNewExtras,PendingIntent.FLAG_CANCEL_CURRENT); This is the right way and will ensure that your new values are delivered. Hope it helps.

Delete alarm from AlarmManager using cancel() – Android

Try this flag: PendingIntent.FLAG_UPDATE_CURRENT Instead of: PendingIntent.FLAG_CANCEL_CURRENT So the PendingIntent will look like this: PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, alert.idAlert, intent, PendingIntent.FLAG_UPDATE_CURRENT) (Make sure that you use same alert object and mContext!) A side note: If you want one global AlarmManager, put the AlarmManager in a static variable (and initialize it only if it’s null).

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

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 StickyService extends Service { private static final String TAG = “StickyService”; @Override public IBinder onBind(Intent arg0) … Read more

Sound alarm when code finishes

On Windows import winsound duration = 1000 # milliseconds freq = 440 # Hz winsound.Beep(freq, duration) Where freq is the frequency in Hz and the duration is in milliseconds. On Linux and Mac import os duration = 1 # seconds freq = 440 # Hz os.system(‘play -nq -t alsa synth {} sine {}’.format(duration, freq)) In … Read more