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());
}
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());
}
use of android.app.TaskStackBuilder in project xDrip by NightscoutFoundation.
the class Notifications method createOngoingNotification.
/* private Notification createExtensionPage(long hours) {
return new NotificationCompat.Builder(mContext)
.extend(new NotificationCompat.WearableExtender()
.setBackground(createWearBitmap(hours))
.setHintShowBackgroundOnly(true)
.setHintAvoidBackgroundClipping(true)
)
.build();
}*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public synchronized Notification createOngoingNotification(BgGraphBuilder bgGraphBuilder, Context context) {
mContext = context;
ReadPerfs(mContext);
Intent intent = new Intent(mContext, Home.class);
List<BgReading> lastReadings = BgReading.latest(2);
BgReading lastReading = null;
if (lastReadings != null && lastReadings.size() >= 2) {
lastReading = lastReadings.get(0);
}
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
stackBuilder.addParentStack(Home.class);
stackBuilder.addNextIntent(intent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
// final NotificationCompat.Builder b = new NotificationCompat.Builder(mContext, NotificationChannels.ONGOING_CHANNEL);
// final NotificationCompat.Builder b = new NotificationCompat.Builder(mContext); // temporary fix until ONGOING CHANNEL is silent by default on android 8+
// temporary fix until ONGOING CHANNEL is silent by default on android 8+
final Notification.Builder b = new Notification.Builder(mContext);
// b.setOngoing(true); // TODO CHECK THIS!!
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
b.setVisibility(Pref.getBooleanDefaultFalse("public_notifications") ? Notification.VISIBILITY_PUBLIC : Notification.VISIBILITY_PRIVATE);
b.setCategory(NotificationCompat.CATEGORY_STATUS);
}
if (Pref.getBooleanDefaultFalse("high_priority_notifications")) {
b.setPriority(Notification.PRIORITY_HIGH);
}
final BestGlucose.DisplayGlucose dg = (use_best_glucose) ? BestGlucose.getDisplayGlucose() : null;
// could be preference option
final boolean use_color_in_notification = false;
final SpannableString titleString = new SpannableString(lastReading == null ? "BG Reading Unavailable" : (dg != null) ? (dg.spannableString(dg.unitized + " " + dg.delta_arrow, use_color_in_notification)) : (lastReading.displayValue(mContext) + " " + lastReading.slopeArrow()));
b.setContentTitle(titleString).setContentText("xDrip Data collection service is running.").setSmallIcon(R.drawable.ic_action_communication_invert_colors_on).setUsesChronometer(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// user has a chance to disable the feature
if (SystemClock.uptimeMillis() > Constants.MINUTE_IN_MS * 15) {
if (NumberGraphic.numberIconEnabled()) {
if ((dg != null) && (!dg.isStale())) {
final Bitmap icon_bitmap = NumberGraphic.getBitmap(dg.unitized);
if (icon_bitmap != null)
b.setSmallIcon(Icon.createWithBitmap(icon_bitmap));
}
}
}
}
if (lastReading != null) {
b.setWhen(lastReading.timestamp);
final SpannableString deltaString = new SpannableString("Delta: " + ((dg != null) ? (dg.spannableString(dg.unitized_delta + (dg.from_plugin ? " " + context.getString(R.string.p_in_circle) : ""))) : bgGraphBuilder.unitizedDeltaString(true, true)));
b.setContentText(deltaString);
iconBitmap = new BgSparklineBuilder(mContext).setHeight(64).setWidth(64).setStart(System.currentTimeMillis() - 60000 * 60 * 3).setBgGraphBuilder(bgGraphBuilder).setBackgroundColor(getCol(X.color_notification_chart_background)).build();
b.setLargeIcon(iconBitmap);
Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle();
notifiationBitmap = new BgSparklineBuilder(mContext).setBgGraphBuilder(bgGraphBuilder).showHighLine().showLowLine().setStart(System.currentTimeMillis() - 60000 * 60 * 3).showAxes(true).setBackgroundColor(getCol(X.color_notification_chart_background)).setShowFiltered(DexCollectionType.hasFiltered() && Pref.getBooleanDefaultFalse("show_filtered_curve")).build();
bigPictureStyle.bigPicture(notifiationBitmap).setSummaryText(deltaString).setBigContentTitle(titleString);
b.setStyle(bigPictureStyle);
}
b.setContentIntent(resultPendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
b.setLocalOnly(true);
}
return b.build();
}
use of android.app.TaskStackBuilder in project butter-android by butterproject.
the class RecommendationService method buildPendingIntent.
private PendingIntent buildPendingIntent(final MediaWrapper media) {
// TODO: 6/17/17 Pending intent can not rely on provider position
Intent detailIntent = TVMediaDetailActivity.getIntent(this, media);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(TVMediaDetailActivity.class);
stackBuilder.addNextIntent(detailIntent);
// Ensure a unique PendingIntents, otherwise all recommendations end up with the same
// PendingIntent
detailIntent.setAction(media.getMedia().getId());
PendingIntent intent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
return intent;
}
use of android.app.TaskStackBuilder in project xDrip-plus by jamorham.
the class Notifications method createOngoingNotification.
/* private Notification createExtensionPage(long hours) {
return new NotificationCompat.Builder(mContext)
.extend(new NotificationCompat.WearableExtender()
.setBackground(createWearBitmap(hours))
.setHintShowBackgroundOnly(true)
.setHintAvoidBackgroundClipping(true)
)
.build();
}*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public synchronized Notification createOngoingNotification(BgGraphBuilder bgGraphBuilder, Context context) {
mContext = context;
ReadPerfs(mContext);
Intent intent = new Intent(mContext, Home.class);
List<BgReading> lastReadings = BgReading.latest(2);
BgReading lastReading = null;
if (lastReadings != null && lastReadings.size() >= 2) {
lastReading = lastReadings.get(0);
}
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
stackBuilder.addParentStack(Home.class);
stackBuilder.addNextIntent(intent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
// final NotificationCompat.Builder b = new NotificationCompat.Builder(mContext, NotificationChannels.ONGOING_CHANNEL);
// final NotificationCompat.Builder b = new NotificationCompat.Builder(mContext); // temporary fix until ONGOING CHANNEL is silent by default on android 8+
// temporary fix until ONGOING CHANNEL is silent by default on android 8+
final Notification.Builder b = new Notification.Builder(mContext);
// b.setOngoing(true); // TODO CHECK THIS!!
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
b.setVisibility(Pref.getBooleanDefaultFalse("public_notifications") ? Notification.VISIBILITY_PUBLIC : Notification.VISIBILITY_PRIVATE);
b.setCategory(NotificationCompat.CATEGORY_STATUS);
}
if (Pref.getBooleanDefaultFalse("high_priority_notifications")) {
b.setPriority(Notification.PRIORITY_HIGH);
}
final BestGlucose.DisplayGlucose dg = (use_best_glucose) ? BestGlucose.getDisplayGlucose() : null;
// could be preference option
final boolean use_color_in_notification = false;
final SpannableString titleString = new SpannableString(lastReading == null ? "BG Reading Unavailable" : (dg != null) ? (dg.spannableString(dg.unitized + " " + dg.delta_arrow, use_color_in_notification)) : (lastReading.displayValue(mContext) + " " + lastReading.slopeArrow()));
b.setContentTitle(titleString).setContentText("xDrip Data collection service is running.").setSmallIcon(R.drawable.ic_action_communication_invert_colors_on).setUsesChronometer(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// user has a chance to disable the feature
if (SystemClock.uptimeMillis() > Constants.MINUTE_IN_MS * 15) {
if (NumberGraphic.numberIconEnabled()) {
if ((dg != null) && (!dg.isStale())) {
final Bitmap icon_bitmap = NumberGraphic.getBitmap(dg.unitized);
if (icon_bitmap != null)
b.setSmallIcon(Icon.createWithBitmap(icon_bitmap));
}
}
}
}
if (lastReading != null) {
b.setWhen(lastReading.timestamp);
final SpannableString deltaString = new SpannableString("Delta: " + ((dg != null) ? (dg.spannableString(dg.unitized_delta + (dg.from_plugin ? " " + context.getString(R.string.p_in_circle) : ""))) : bgGraphBuilder.unitizedDeltaString(true, true)));
b.setContentText(deltaString);
iconBitmap = new BgSparklineBuilder(mContext).setHeight(64).setWidth(64).setStart(System.currentTimeMillis() - 60000 * 60 * 3).setBgGraphBuilder(bgGraphBuilder).setBackgroundColor(getCol(X.color_notification_chart_background)).build();
b.setLargeIcon(iconBitmap);
Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle();
notifiationBitmap = new BgSparklineBuilder(mContext).setBgGraphBuilder(bgGraphBuilder).showHighLine().showLowLine().setStart(System.currentTimeMillis() - 60000 * 60 * 3).showAxes(true).setBackgroundColor(getCol(X.color_notification_chart_background)).setShowFiltered(DexCollectionType.hasFiltered() && Pref.getBooleanDefaultFalse("show_filtered_curve")).build();
bigPictureStyle.bigPicture(notifiationBitmap).setSummaryText(deltaString).setBigContentTitle(titleString);
b.setStyle(bigPictureStyle);
}
b.setContentIntent(resultPendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
b.setLocalOnly(true);
}
return b.build();
}
Aggregations