我需要在Android Notification
上显示GingerBread
,但我使用的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?
答案 0 :(得分:0)
TaskStackBuilder在Android上工作正常< 3.0,您只需使用支持库中的版本。