android - 通知 BigPictureStyle 在 6.0 之前和之后的设备上扩展
问题描述
我阅读了很多关于此的主题,但没有找到任何解决方案。我正在使用 FMC 通知并使用以下方法显示它们:
public static void sendNotification(Context context, int id, String title, String bitmapUrl) {
Bitmap bitmap = getBitmapfromUrl(bitmapUrl);
Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("id", id);
intent.putExtra("title", title);
PendingIntent pendingIntent = PendingIntent.getActivity(context, Constants.REQUEST_CODE_POST_DETAIL, intent,
PendingIntent.FLAG_ONE_SHOT);
String channelId = context.getString(R.string.default_notification_channel_id);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(context.getResources().getString(R.string.app_name))
.setStyle(
new NotificationCompat
.BigPictureStyle()
.bigPicture(bitmap)
.bigLargeIcon(bitmap)
.setBigContentTitle(title)
)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(id, notificationBuilder.build());
}
我阅读了很多关于此的主题,但没有找到任何解决方案。
我已经读过只有堆栈顶部的通知应该显示为展开。在 6.0 之前的设备中,确切地说是 5.0.2 的华为,这总是很有效,第一个通知显示已经展开。在 6.0 之后的设备中,确切地说是 6.0.1 的华为,我的应用程序的 nofitiche 始终显示为折叠状态,并且只有向下滑动通知时它才会展开。
我尝试了其他代码示例,阅读了 android 文档,但没有解决问题。我还使用自定义通知来扩展单独的布局 xml,但它们在两个 android 版本中具有不同的行为并显示相同的问题。
我不明白为什么其他应用程序(例如 youtube)显示正确扩展的通知,所以这意味着方式是......
谁能澄清是否有办法至少显示第一个扩展通知,该通知至少适用于 5.0 及更高版本的所有版本?谢谢
解决方案
推荐阅读
- sql - 为什么 sum 函数只显示单个结果?
- javascript - JS函数不会在按钮单击时初始化
- sql - Ruby on Rails 难查询
- angular - 如何使用角度在浏览器的新选项卡中实现打开链接?
- hadoop - 有没有办法 hadoop getmerge 部分文件不是所有文件?
- python - 使用 Python ctypes 作为示例从 Ruby 中 FFI 中包装的 C 库获取返回值的问题
- php - 致命错误:未捕获的错误:调用 C 中 bool 上的成员函数 execute() 堆栈跟踪:#0 require() #1 {main} 在第 31 行的 C 中抛出
- angular - Highcharts没有以角度旋转到垂直
- c# - 减去 2 个列表
- html - 选择选项框的高度