我正在尝试使用Notification在Android中显示RemoteView。我无法弄清楚有什么问题可以帮助我:
以下是我的代码
Bitmap bitmap = MediaManager.getAlbumArt(id, getApplicationContext());
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.remote_layout);
remoteViews.setTextViewText(R.id.remote_title, title);
remoteViews.setTextViewText(R.id.remote_album, album);
remoteViews.setImageViewResource(R.id.remote_art,
R.drawable.ic_launcher);
// if (bitmap != null)
// remoteViews.setImageViewBitmap(R.id.remote_art, bitmap);
// else
// remoteViews.setImageViewResource(R.id.remote_art,
// R.drawable.ic_launcher);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
this).setContent(remoteViews).setContentText("SOME TEXT");
Intent intent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = builder.build();
// manager.notify(25, notification);
startService(new Intent(this, MediaServiceContoller.class));
startForeground(25, notification);