Я пытаюсь создать контроллер мультимедиа для уведомлений в своем приложении, используя приведенный ниже код, который работает нормально на всех устройствах, ожидающих Huawei P8 Lite с Android 5.0 , я получаю это журнал ошибок из Firebase Test Lab:
android.app.RemoteServiceException: отправлено плохое уведомление от
пакет maa.app_app: не удалось развернуть RemoteViews для:
StatusBarNotification (PKG = maa.app_app
user = UserHandle {0} id = 555 tag = нулевая оценка = 10
key = 0 | maa.app_app | 555 | null | 10108: Уведомление (pri = 1
contentView = maa.app_app / 0x109007f vibrate = null
sound = null default = 0x0 flags = 0x62 color = 0xffbfbfbf category = transport
actions = 2 vis = PUBLIC)) FATAL EXCEPTION: main Процесс:
maa.app_app, PID: 18793
android.app.RemoteServiceException: плохое уведомление от
пакет maa.app_app: не удалось развернуть RemoteViews для:
StatusBarNotification (PKG = maa.app_app
user = UserHandle {0} id = 555 tag = нулевая оценка = 10
key = 0 | maa.app_app | 555 | null | 10108: Уведомление (pri = 1
contentView = maa.app_app / 0x109007f vibrate = null
sound = null default = 0x0 flags = 0x62 color = 0xffbfbfbf category = transport
действия = 2 vis = ОБЩЕСТВЕННЫЕ)) в
android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1534)
на android.os.Handler.dispatchMessage (Handler.java:102) на
android.os.Looper.loop (Looper.java:135) в
android.app.ActivityThread.main (ActivityThread.java:5538) в
java.lang.reflect.Method.invoke (родной метод) в
java.lang.reflect.Method.invoke (Method.java:372) в
com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:960)
на com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)
вот мой код:
void startNotify(Context context, String playbackStatus, String title) {
String titlesonge;
String artist;
try {
titlesonge = StringUtils.substringBefore(title, " - ");
artist = StringUtils.substringAfter(title, " - ");
} catch (Exception e) {
titlesonge = title.substring(0, title.indexOf(" - "));
artist = title.substring(title.lastIndexOf(" - ") - 1);
}
int icon = R.drawable.ic_pause_white;
Intent playbackAction = new Intent(service, RadioService.class);
playbackAction.setAction(RadioService.ACTION_PAUSE);
PendingIntent action = PendingIntent.getService(service, 1, playbackAction, 0);
if (playbackStatus.equals(PlaybackStatus.PAUSED)) {
icon = R.drawable.ic_play_white;
playbackAction.setAction(RadioService.ACTION_PLAY);
action = PendingIntent.getService(service, 2, playbackAction, 0);
}
Intent stopIntent = new Intent(service, RadioService.class);
stopIntent.setAction(RadioService.ACTION_STOP);
PendingIntent stopAction = PendingIntent.getService(service, 3, stopIntent, 0);
Intent intent = new Intent(service, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(service, 0, intent, 0);
notificationManager.cancel(NOTIFICATION_ID);
String PRIMARY_CHANNEL = "PRIMARY_CHANNEL_ID";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager manager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE);
String PRIMARY_CHANNEL_NAME = "PRIMARY";
NotificationChannel channel = new NotificationChannel(PRIMARY_CHANNEL, PRIMARY_CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
if (manager != null) {
manager.createNotificationChannel(channel);
}
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(service, PRIMARY_CHANNEL)
.setAutoCancel(false)
.setContentTitle(titlesonge)
.setContentText(artist)
.setLargeIcon(BitmapFactory.decodeResource(resources, R.drawable.largeicon))
.setContentIntent(pendingIntent)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setSmallIcon(R.drawable.smallwidth)
.setColor(ContextCompat.getColor(context, R.color.colorneeded))
.addAction(icon, "pause", action)
.addAction(R.drawable.ic_stop_white, "stop", stopAction)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
.setMediaSession(service.getMediaSession().getSessionToken())
.setShowActionsInCompactView(0, 1)
.setShowCancelButton(true)
.setCancelButtonIntent(stopAction));
service.startForeground(NOTIFICATION_ID, builder.build());
}
Может кто-нибудь помочь мне решить эту проблему