Search in sources :

Example 31 with TaskStackBuilder

use of android.support.v4.app.TaskStackBuilder in project iosched by google.

the class ActivityUtils method createBackStack.

/**
     * Enables back navigation for activities that are launched from the NavBar. See {@code
     * AndroidManifest.xml} to find out the parent activity names for each activity.
     *
     * @param intent
     */
public static void createBackStack(Activity activity, Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(activity);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        activity.startActivity(intent);
        activity.finish();
    }
}
Also used : TaskStackBuilder(android.support.v4.app.TaskStackBuilder)

Example 32 with TaskStackBuilder

use of android.support.v4.app.TaskStackBuilder in project DeepLinkDispatch by airbnb.

the class MainActivity method intentForTaskStackBuilderMethods.

@DeepLink("http://example.com/deepLink/{id}/{name}/{place}")
public static TaskStackBuilder intentForTaskStackBuilderMethods(Context context, Bundle bundle) {
    Log.d(TAG, "without query parameter :");
    if (bundle != null && bundle.containsKey("qp")) {
        Log.d(TAG, "found new parameter :with query parameter :" + bundle.getString("qp"));
    }
    Intent detailsIntent = new Intent(context, SecondActivity.class).setAction(ACTION_DEEP_LINK_COMPLEX);
    Intent parentIntent = new Intent(context, MainActivity.class).setAction(ACTION_DEEP_LINK_COMPLEX);
    TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
    taskStackBuilder.addNextIntent(parentIntent);
    taskStackBuilder.addNextIntent(detailsIntent);
    return taskStackBuilder;
}
Also used : Intent(android.content.Intent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) DeepLink(com.airbnb.deeplinkdispatch.DeepLink)

Example 33 with TaskStackBuilder

use of android.support.v4.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 34 with TaskStackBuilder

use of android.support.v4.app.TaskStackBuilder in project AprilBeacon-Android-SDK by AprilBrother.

the class NotifyService method setCustomViewNotification.

/**
	 * Custom View Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setCustomViewNotification(String content) {
    // Creates an explicit intent for an ResultActivity to receive.
    Intent resultIntent = new Intent(this, ResultActivity.class);
    // This ensures that the back button follows the recommended convention
    // for the back key.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(ResultActivity.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);
    // Create remote view and set bigContentView.
    RemoteViews expandedView = new RemoteViews(this.getPackageName(), R.layout.notification_custom_remote);
    expandedView.setTextViewText(R.id.text_view, "Neat logo!");
    Notification notification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true).setContentIntent(resultPendingIntent).setContentTitle("Custom View").build();
    return notification;
}
Also used : RemoteViews(android.widget.RemoteViews) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) Notification(android.app.Notification)

Example 35 with TaskStackBuilder

use of android.support.v4.app.TaskStackBuilder in project AprilBeacon-Android-SDK by AprilBrother.

the class NotifyService method setBigPictureStyleNotification.

/**
	 * Big Picture Style Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setBigPictureStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with BigPictureStyle subclass.
    NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
    notiStyle.setBigContentTitle("Big Picture Expanded");
    notiStyle.setSummaryText("Nice big picture.");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // Add the big picture to the style.
    notiStyle.bigPicture(remote_picture);
    // Creates an explicit intent for an ResultActivity to receive.
    Intent resultIntent = new Intent(this, ResultActivity.class);
    // This ensures that the back button follows the recommended convention
    // for the back key.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself).
    stackBuilder.addParentStack(ResultActivity.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);
    return new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true).setLargeIcon(remote_picture).setContentIntent(resultPendingIntent).addAction(R.drawable.ic_launcher, "One", resultPendingIntent).addAction(R.drawable.ic_launcher, "Two", resultPendingIntent).addAction(R.drawable.ic_launcher, "Three", resultPendingIntent).setContentTitle("Big Picture Normal").setContentText(content).setStyle(notiStyle).build();
}
Also used : Bitmap(android.graphics.Bitmap) InputStream(java.io.InputStream) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) IOException(java.io.IOException) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) URL(java.net.URL)

Aggregations

Intent (android.content.Intent)40 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)40 PendingIntent (android.app.PendingIntent)35 NotificationCompat (android.support.v4.app.NotificationCompat)21 NotificationManager (android.app.NotificationManager)14 Bitmap (android.graphics.Bitmap)13 InputStream (java.io.InputStream)10 IOException (java.io.IOException)8 URL (java.net.URL)8 Notification (android.app.Notification)7 Context (android.content.Context)5 Uri (android.net.Uri)5 SharedPreferences (android.content.SharedPreferences)3 Resources (android.content.res.Resources)3 Cursor (android.database.Cursor)3 Bundle (android.os.Bundle)3 RemoteViews (android.widget.RemoteViews)3 TaskStackBuilder (android.app.TaskStackBuilder)2 ContentResolver (android.content.ContentResolver)2 NonNull (android.support.annotation.NonNull)2