我的通知未显示状态栏上的文字,但声音和其他选项完美无缺。我在Android L上,这是某种错误吗?
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(LocalService.this)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(largeIcon)
.setTicker("Ticker Text")
.setContentTitle(notificationTitle)
.setContentText(notificationContent)
.setSound(ringtoneUri)
.setAutoCancel(true);
Intent resultIntent = new Intent(LocalService.this, ResultActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(LocalService.this);
stackBuilder.addParentStack(ResultActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(mId, mBuilder.build());
答案 0 :(得分:2)
答案 1 :(得分:0)
根据Google API document about Notification
,这似乎不是一个错误总结此无障碍服务通知的文本。从L版本开始,此文本不再显示在屏幕上,但它仍然对辅助功能服务有用(它可以作为通知外观的声音通知)。
所以在Android L之后,我们无法在屏幕上显示tickerText。有关详细信息,请查看Android Police article。