Android examples for Android OS:Alarm Cancel
stop Alarm Service by Class<?>
//package com.java2s; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; public class Main { public static void stopPollingService(Context context, Class<?> cls, String action) {// w w w . j ava 2s. co m AlarmManager manager = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, cls); if (action != null && action.trim() != "") { intent.setAction(action); } PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); manager.cancel(pendingIntent); } }