Bud*_*ius 18 notifications android android-notifications
我正在使用兼容性库实现Android丰富的通知,所以我的所有通知都是使用构建的 android.support.v4.app.NotificationCompat.Builder
我正在使用的代码如下:
// Base notification
NotificationCompat.Builder b = new NotificationCompat.Builder(context);
b.setSmallIcon(R.drawable.ic_actionbar);
b.setContentTitle(title);
b.setContentText(Html.fromHtml(msg));
b.setTicker(title);
b.setWhen(System.currentTimeMillis());
b.setDeleteIntent(getDismissNotificationsPendingIntent(quantity));
b.setLargeIcon(Picasso.with(context).load(iconUrl).get());
// BigPictureStyle
NotificationCompat.BigPictureStyle s = new NotificationCompat.BigPictureStyle();
if (expandedIconUrl != null) {
s.bigLargeIcon(Picasso.with(context).load(expandedIconUrl).get());
} else if (expandedIconResId > 0) {
s.bigLargeIcon(BitmapFactory.decodeResource(context.getResources(), expandedIconResId));
}
s.bigPicture(Picasso.with(context).load(bigImageUrl).get());
b.setStyle(s);
b.setContentIntent( // some intent
b.addAction(R.drawable.ic_notification_ // some action
Notification n = b.build();
// and go ahead to show it
Run Code Online (Sandbox Code Playgroud)
如果显示图像不兼容,基本上没有加载任何图像,所以我们不会无缘无故地使用内存,但这是基础,我期待类似于下图中右边的通知

问题是消息(在示例"触摸以查看屏幕截图.")显示通知何时签约,但是当通知扩展时,消息消失.
有什么setMessage()方法我忘记打电话了吗?这是一个错误NotificationCompat吗?谁能在这里提供一些见解?
| 归档时间: |
|
| 查看次数: |
9751 次 |
| 最近记录: |