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();
}
}
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;
}
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());
}
}
}
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;
}
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();
}
Aggregations