Example usage for android.app PendingIntent getActivity

List of usage examples for android.app PendingIntent getActivity

Introduction

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

Prototype

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

Source Link

Document

Retrieve a PendingIntent that will start a new activity, like calling Context#startActivity(Intent) Context.startActivity(Intent) .

Usage

From source file:Main.java

public static PendingIntent getDefalutIntent(Context context, int flags) {
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, new Intent(), flags);
    return pendingIntent;
}

From source file:Main.java

public static void setClickPendingIntent(RemoteViews remoteButton, Intent intent, Context context,
        int buttonId) {

    PendingIntent clickPI = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    remoteButton.setOnClickPendingIntent(buttonId, clickPI);
}

From source file:Main.java

static PendingIntent createOpenCalendarEventPendingIntent(Context context) {
    Intent intent = createCalendarIntent(Intent.ACTION_VIEW);
    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:Main.java

public static void notify(Context context, String msg, String title, Class<?> toClz, int notifyId) {
    PendingIntent pend = PendingIntent.getActivity(context, 0, new Intent(context, toClz), 0);
    Notification.Builder builder = new Notification.Builder(context);
    int icon = context.getApplicationInfo().icon;
    builder.setContentIntent(pend).setSmallIcon(icon).setWhen(System.currentTimeMillis()).setTicker(msg)
            .setContentTitle(title).setContentText(msg).setAutoCancel(true);

    NotificationManager man = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    man.notify(notifyId, builder.getNotification());
}

From source file:Main.java

private static PendingIntent makeMoodIntent(Context context, Class class1) {
    Intent intent = new Intent(context, class1);
    intent.addFlags(0x400000);/*from  w  w  w .j  av  a  2 s.c  o m*/
    intent.addFlags(0x4000000);
    return PendingIntent.getActivity(context, 1, intent, 0x10000000);
}

From source file:Main.java

public static void exitAndRestart(Context context, Class<?> activityCls) {
    Intent intent = new Intent(context, activityCls);
    PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    mgr.set(1, System.currentTimeMillis() + 1000L, restartIntent);
}

From source file:Main.java

public static PendingIntent createNewEventPendingIntent(Context context) {
    Intent intent = createNewEventIntent();
    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:Main.java

/**
 * Restart the app./*  w w w .  j  a  v a 2s . c o  m*/
 * @param context
 */
public static void restartApplication(Context context) {
    Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent p = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 500, p);

    //kill the application
    System.exit(0);
}

From source file:Main.java

public static final void BindClickActionActivity(final Context context, final RemoteViews views,
        final int resId, final int widgetId, final Intent intent) {
    final int requestCode = generateRequestCode(resId, widgetId);
    PendingIntent pIntent = PendingIntent.getActivity(context, requestCode, intent, PENDING_INTENT_FLAGS);
    views.setOnClickPendingIntent(resId, pIntent);
}

From source file:Main.java

public static void updateProgressNotification(Context context, int notifiId, String title, int progress) {
    Notification notification = new NotificationCompat.Builder(context).setAutoCancel(true).setTicker(title)
            .setContentTitle(title).setContentText("Downloading..." + progress + "%")
            .setProgress(100, progress, false)
            .setContentIntent(/* w  w  w.  j  a  v  a 2 s  .c o m*/
                    PendingIntent.getActivity(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT))
            .setSmallIcon(android.R.drawable.stat_sys_download).build();
    updateNotification(context, notifiId, notification);
}