Search in sources :

Example 6 with TaskStackBuilder

use of android.app.TaskStackBuilder in project Parse-SDK-Android by ParsePlatform.

the class TaskStackBuilderHelper method startActivities.

public static void startActivities(Context context, Class<? extends Activity> cls, Intent activityIntent) {
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(cls);
    stackBuilder.addNextIntent(activityIntent);
    stackBuilder.startActivities();
}
Also used : TaskStackBuilder(android.app.TaskStackBuilder)

Example 7 with TaskStackBuilder

use of android.app.TaskStackBuilder in project Fairphone by Kwamecorp.

the class PeaceOfMindBroadCastReceiver method setPeaceOfMindIconInNotificationBar.

/**
	 * Sets the Peace of mind icon on the notification bar
	 * @param putIcon if true the icon is put otherwise it is removed
	 * @param wasInterrupted when true, an extra notification is sent to inform the user that Peace of mind was ended
	 */
private void setPeaceOfMindIconInNotificationBar(boolean putIcon, boolean wasInterrupted) {
    NotificationManager manager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    if (putIcon) {
        //just in case the user didn't clear it
        manager.cancel(PEACE_OF_MIND_INTERRUPTED_NOTIFICATION);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.peace_system_bar_icon).setContentTitle(mContext.getResources().getString(R.string.app_name)).setContentText(mContext.getResources().getString(R.string.peace_on_notification));
        Intent resultIntent = new Intent(mContext, PeaceOfMindActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(PeaceOfMindActivity.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        builder.setContentIntent(resultPendingIntent);
        Notification notificationWhileRunnig = builder.build();
        notificationWhileRunnig.flags |= Notification.FLAG_NO_CLEAR;
        // Add notification   
        manager.notify(PEACE_OF_MIND_ON_NOTIFICATION, notificationWhileRunnig);
    } else {
        manager.cancel(PEACE_OF_MIND_ON_NOTIFICATION);
        //send a notification saying that the peace was ended 
        if (wasInterrupted) {
            NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.peace_system_bar_icon).setAutoCancel(true).setContentTitle(mContext.getResources().getString(R.string.app_name)).setContentText(mContext.getResources().getString(R.string.peace_off_notification)).setTicker(mContext.getResources().getString(R.string.peace_off_notification));
            manager.notify(PEACE_OF_MIND_INTERRUPTED_NOTIFICATION, builder.build());
        }
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.app.TaskStackBuilder) Notification(android.app.Notification)

Example 8 with TaskStackBuilder

use of android.app.TaskStackBuilder in project android_frameworks_base by AOSPA.

the class MainActivity method sendNotification.

private void sendNotification(int count) {
    Notification.Builder builder = new Notification.Builder(this).setContentTitle(String.format("%s OSU available", count)).setContentText("Choose one to connect").setSmallIcon(android.R.drawable.ic_dialog_info).setAutoCancel(false);
    Intent resultIntent = new Intent(this, MainActivity.class);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, builder.build());
}
Also used : NotificationManager(android.app.NotificationManager) TaskStackBuilder(android.app.TaskStackBuilder) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.app.TaskStackBuilder) Notification(android.app.Notification)

Example 9 with TaskStackBuilder

use of android.app.TaskStackBuilder in project android_frameworks_base by crdroidandroid.

the class MainActivity method sendNotification.

private void sendNotification(int count) {
    Notification.Builder builder = new Notification.Builder(this).setContentTitle(String.format("%s OSU available", count)).setContentText("Choose one to connect").setSmallIcon(android.R.drawable.ic_dialog_info).setAutoCancel(false);
    Intent resultIntent = new Intent(this, MainActivity.class);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, builder.build());
}
Also used : NotificationManager(android.app.NotificationManager) TaskStackBuilder(android.app.TaskStackBuilder) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.app.TaskStackBuilder) Notification(android.app.Notification)

Aggregations

TaskStackBuilder (android.app.TaskStackBuilder)9 Notification (android.app.Notification)8 NotificationManager (android.app.NotificationManager)8 PendingIntent (android.app.PendingIntent)8 Intent (android.content.Intent)8 NotificationCompat (android.support.v4.app.NotificationCompat)2 Context (android.content.Context)1 NotificationCompat (android.support.v7.app.NotificationCompat)1 ExpenseDetailActivity (com.polito.mad17.madmax.activities.expenses.ExpenseDetailActivity)1 PendingExpenseDetailActivity (com.polito.mad17.madmax.activities.expenses.PendingExpenseDetailActivity)1 GroupDetailActivity (com.polito.mad17.madmax.activities.groups.GroupDetailActivity)1