Android examples for Android OS:Alarm Cancel
cancel Alarm via SharedPreferences
import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.text.format.Time; import java.util.Random; public class Main{ public static void cancelAlarm(Context context) { Intent i = new Intent(context, Receiver.class); PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0); AlarmManager alarmManager = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pi);//from w w w . j a v a 2 s . c o m SharedPreferences sp = PreferenceManager .getDefaultSharedPreferences(context); sp.edit().putString("alarm_time", "Alarm disabled").commit(); } }