[英]TaskStackBuilder on older version Android
我需要在Android GingerBread
上顯示Notification
,但是我使用的TaskStackBuilder
從Android 3及更高版本開始使用。
NotificationCompat.Builder notification =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.red)
.setContentTitle("Notification.")
.setContentText(incomingNumber);
Intent resultIntent = new Intent(context, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
notification.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, notification.build());
如何在Android <v3.0上執行此操作?
TaskStackBuilder在Android <3.0上運行良好,您只需要使用支持庫中的版本即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.