질문이 있습니다. 클릭하면 '재생'이미지로 '일시 중지'변경 알림을 업데이트하고 싶습니다. 그러나 나는이 오류가 계속 :알림 이미지를 변경하는 중에 오류가 발생했습니다.
android.app.RemoteServiceException: Bad notification posted from package m.com.musicbox: Couldn't expand RemoteViews for:StatusBarNotification(pkg=m.com.musicbox user=UserHandle{0} id=522 tag=null score=0: Notification(pri=0 icon=7f020067 contentView=m.com.musicbox/0x7f03003d vibrate=null sound=null defaults=0x0 flags=0x2 when=1416463928948 ledARGB=0x0 contentIntent=Y deleteIntent=N contentTitle=N contentText=N tickerText=N kind=[null]))
이 RemoteView
, NotificationManager
및 Notification
, 나는 업데이트 이전과 동일하게 사용하고 있습니다. 이 솔루션을 찾으려고 시도하기 때문에 이것이 올바른지 확실하지 않습니다. 희망은 누구든지 도울 수 있습니다.
void updateNotification() {
if (Utils.isStatus.equalsIgnoreCase("pause")) {
notificationView.setImageViewResource(R.id.play, R.drawable.ic_pause);
} else {
notificationView.setImageViewResource(R.id.play, R.drawable.ic_play);
}
notificationManager.notify(id, notification);
}
public void setNotification() {
String ns = Context.NOTIFICATION_SERVICE;
notificationManager = (NotificationManager) getSystemService(ns);
notification = new Notification(R.drawable.ic_launcher, null,
System.currentTimeMillis());
notificationView = new RemoteViews(getPackageName(),
R.layout.notification_bar);
Intent notificationIntent = new Intent(context, Player.class);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(
this, 0, notificationIntent, 0);
notification.contentView = notificationView;
notification.contentIntent = pendingNotificationIntent;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
Intent intentPlay = new Intent("m.com.musicbox.ACTION_PLAY");
PendingIntent pendingPlayIntent = PendingIntent.getBroadcast(context,
100, intentPlay, 0);
Intent intentPrev = new Intent("m.com.musicbox.ACTION_PREVIOUS");
PendingIntent pendingPrevIntent = PendingIntent.getBroadcast(context,
100, intentPrev, 0);
Intent intentNext = new Intent("m.com.musicbox.ACTION_NEXT");
PendingIntent pendingNextIntent = PendingIntent.getBroadcast(context,
100, intentNext, 0);
Intent intentClose = new Intent("m.com.musicbox.ACTION_CLOSE");
PendingIntent pendingCloseIntent = PendingIntent.getBroadcast(context,
100, intentClose, 0);
notificationView.setOnClickPendingIntent(R.id.play, pendingPlayIntent);
notificationView.setOnClickPendingIntent(R.id.prev, pendingPrevIntent);
notificationView.setOnClickPendingIntent(R.id.next, pendingNextIntent);
notificationView
.setOnClickPendingIntent(R.id.close, pendingCloseIntent);
notificationManager.notify(id, notification);
}
방금이 같은 노력 않았다 "notification.icon = R.drawable.icon;" – JRowan