我正在尝试实现BigPictureStyle,但它不起作用。推送消息工作但没有大图像。图片网址不为空。我用Adobe管理推送了推送。 还尝试使用RemoteViews但它也不起作用。 请帮助!
public class FCMListenerService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
/*call sendNotification*/
}
private void sendNotification(String title,
String message,
String type,
String id,
String deepLink,
final String imageUrl,
Bundle fbPushBundle) {
Intent intent = new Intent(this, LoginActivity.class);
if (fbPushBundle != null)
intent.putExtra("push", fbPushBundle);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (deepLink != null && !deepLink.isEmpty()) {
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.parse(type);
intent.setData(uri);
}
intent.putExtra("type", type);
intent.putExtra("id", id);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_push_app_icon))
.setSmallIcon(R.mipmap.ic_push_icon)
.setContentTitle(title)
.setContentText(message)
.setColor(ContextCompat.getColor(FCMListenerService.this, R.color.theme_yellow))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setDefaults(Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE)
.setContentIntent(pendingIntent);
Bitmap largeImage = null;
if (imageUrl != null) {
try {
largeImage = Picasso.with(this).load(imageUrl).get();
if (largeImage!=null){
notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(largeImage));
}
} catch (Exception e) {
e.printStackTrace();
}
}
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify((int) System.currentTimeMillis(), notificationBuilder.build());
}
}
解决 这只是奇怪的小米通知。有必要使用两根手指来扩展通知
答案 0 :(得分:0)
尝试添加内容和标题
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(img).setSummaryText(content).setBigContentTitle(msg))