我想显示一个通知控制器来播放和暂停音乐,但是当我在手机中进行测试时,我在 Android Studio 的 LogCut 中看到此错误日志:
2019-05-18 19:07:46.499 32154-32154 / maa.app_app E / NotificationManager: notifyAsUser:标签=空,ID = 555,用户= UserHandle {0}
代码:
void exoPlayerNotification(Context context, SimpleExoPlayer exoPlayer, String title) {
PlayerNotificationManager mPlayerNotificationManager = PlayerNotificationManager.createWithNotificationChannel(
context,
"PRIMARY_CHANNEL_ID",
R.string.plaza,
555,
new PlayerNotificationManager.MediaDescriptionAdapter() {
@Override
public String getCurrentContentTitle(Player player) {
return finalArtist;
}
@Nullable
@Override
public PendingIntent createCurrentContentIntent(Player player) {
Intent intent = new Intent(service, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
return PendingIntent.getActivity(service, 555, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
}
@Override
public String getCurrentContentText(Player player) {
return finalTitlesonge;
}
@Nullable
@Override
public Bitmap getCurrentLargeIcon(Player player, PlayerNotificationManager.BitmapCallback callback) {
return BitmapFactory.decodeResource(service.getResources(), R.drawable.largeicon);
}
@Nullable
@Override
public String getCurrentSubText(Player player) {
return null;
}
}
);
mPlayerNotificationManager.setUseNavigationActions(false);
mPlayerNotificationManager.setFastForwardIncrementMs(0);
mPlayerNotificationManager.setRewindIncrementMs(0);
mPlayerNotificationManager.setColorized(true);
mPlayerNotificationManager.setColor(0xFFBDBDBD);
mPlayerNotificationManager.setUseChronometer(true);
mPlayerNotificationManager.setOngoing(true);
mPlayerNotificationManager.setPriority(NotificationCompat.PRIORITY_MAX);
mPlayerNotificationManager.setUsePlayPauseActions(true);
mPlayerNotificationManager.setSmallIcon(R.drawable.smallwidth);
mPlayerNotificationManager.setNotificationListener(new PlayerNotificationManager.NotificationListener() {
@Override
public void onNotificationStarted(int notificationId, Notification notification) {
service.startForeground(notificationId, notification);
}
@Override
public void onNotificationCancelled(int notificationId) {
service.stopSelf();
cancelNotify();
}
});
mPlayerNotificationManager.setPlayer(exoPlayer);
}
任何人都可以帮助我解决此问题