Example usage for android.app PendingIntent getBroadcast

List of usage examples for android.app PendingIntent getBroadcast

Introduction

In this page you can find the example usage for android.app PendingIntent getBroadcast.

Prototype

public static PendingIntent getBroadcast(Context context, int requestCode, Intent intent, @Flags int flags) 

Source Link

Document

Retrieve a PendingIntent that will perform a broadcast, like calling Context#sendBroadcast(Intent) Context.sendBroadcast() .

Usage

From source file:Main.java

public static boolean alarmUp(Context context, String action) {
    return PendingIntent.getBroadcast(context, 0, new Intent(action), PendingIntent.FLAG_NO_CREATE) != null;
}

From source file:Main.java

public static boolean hasAlarm(Context context, Intent intent, int notificationId) {
    return PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_NO_CREATE) != null;
}

From source file:Main.java

private static PendingIntent genPendingBroadcast(Context context, int requestCode, Intent broadcastIntent) {
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, requestCode, broadcastIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    return pendingIntent;
}

From source file:Main.java

public static void UnRegister(Context context) {
    Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
    unregIntent.putExtra("app", PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    context.startService(unregIntent);//from w  ww  .  j a va2s .  c  om
}

From source file:Main.java

public static void canalAlarm(Context context, String action) {
    Intent intent = new Intent(action);
    PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    am.cancel(pi);/*from  w  w  w.  j  a  va  2 s  . co m*/
}

From source file:Main.java

public static void cancel(Context context, Intent intent) {
    PendingIntent p = PendingIntent.getBroadcast(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    alarm.cancel(p);//from w  ww.  ja va2 s .  c o  m
    Log.d("petsitter-alarm", "Alarme cancelado.");
}

From source file:Main.java

public static void cancelAlarm(Context context, String action, int id) {
    Intent intent = new Intent(action);
    PendingIntent pi = PendingIntent.getBroadcast(context, id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    am.cancel(pi);//from   www .j a  v  a 2  s .  co m
}

From source file:Main.java

public static void stopAlarm(AlarmManager manager, Context context, Class reciverClsss) {

    Intent intent = new Intent(context, reciverClsss);

    PendingIntent pintent = PendingIntent.getBroadcast(context, 0, intent, 0);

    manager.cancel(pintent);/*  w w w .  j a  v  a2 s  . co m*/

}

From source file:Main.java

public static AlarmManager sendUpdateBroadcastRepeat(Context ctx, Intent intent) {
    pendingIntent = PendingIntent.getBroadcast(ctx, 0, intent, 0);
    am = (AlarmManager) ctx.getSystemService(ctx.ALARM_SERVICE);
    am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 600 * 1000, pendingIntent);
    return am;//from  www. j a  va  2  s.c  om
}

From source file:Main.java

public static void cancelAlarm(Context context, int alarmId, Intent intent) {
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    PendingIntent pi = PendingIntent.getBroadcast(context, alarmId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    alarmManager.cancel(pi);/*w ww .  j a v  a2 s.  c om*/
}