[英]How to create a notification with NotificationCompat.Builder?
[英]Android: How to adjust the largeIcon of a NotificationCompat.Builder in the bounds of the notification
我已经建立了一个通知,但是当我设置大图标时,它不适合边界。 我将其设置为按预期显示。
这是创建通知的代码:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(image)
.setContentTitle(appName)
.setContentText(message)
.setSound(defaultSoundUri)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent);
尝试使用自定义布局显示Notification:
这可以帮助您:
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
RemoteViews contentView = new RemoteViews(pkgName, R.layout.custom_notification);
contentView.setImageViewResource(R.id.notification_image, appIcon);
contentView.setTextViewText(R.id.notification_text, message);
notification.contentView = contentView;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.