get Pending Intent - Android Intent

Android examples for Intent:Pending Intent

Description

get Pending Intent

Demo Code


//package com.java2s;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class Main {

    public static final int MODE_PI_SERVICE = 1;

    public static final int MODE_PI_BROADCAST = 2;

    public static PendingIntent getPendingIntent(Context context, int id,
            int mode, Intent intent) {

        PendingIntent pendingIntent;//from  w  w  w  . j a  v  a2s .  c  o m

        switch (mode) {
        case MODE_PI_SERVICE:
            pendingIntent = PendingIntent.getService(context, id, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            break;
        case MODE_PI_BROADCAST:
            pendingIntent = PendingIntent.getBroadcast(context, id, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            break;
        default:
            pendingIntent = PendingIntent.getActivity(context, id, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            break;
        }

        return pendingIntent;
    }
}

Related Tutorials