вот код моего notification
Код: Выделить всё
public Notification createNotification()
{
RemoteViews views = new RemoteViews(getPackageName(),R.layout.notif);
Song song = new Song(tracks[indexCurrentTrack]);
views.setTextViewText(R.id.notifTitle, song.getTitle());
views.setTextViewText(R.id.notifArtist, song.getArtist() );
Bitmap cover = song.getBitmap(this);
if (cover == null)
{
views.setImageViewResource(R.id.notifAlbum, R.drawable.fallback_cover);
}
else
{
views.setImageViewBitmap(R.id.notifAlbum, cover);
}
int playButton = isPlaying ? R.drawable.notif_pause : R.drawable.notif_play;
views.setImageViewResource(R.id.notifPlay, playButton);
ComponentName componentName = new ComponentName(this,PlayingService.class);
Intent intentPlay = new Intent(actionPlay);
intentPlay.setComponent(componentName);
views.setOnClickPendingIntent(R.id.notifPlay, PendingIntent.getService(this, 0, intentPlay, 0));
Intent intentNext = new Intent(actionNext);
intentNext.setComponent(componentName);
views.setOnClickPendingIntent(R.id.notifNext, PendingIntent.getService(this, 0, intentNext, 0));
Intent intentPrevious = new Intent(actionPrevious);
intentPrevious.setComponent(componentName);
views.setOnClickPendingIntent(R.id.notifPrevious, PendingIntent.getService(this, 0, intentPrevious, 0));
Intent intentClose = new Intent(actionClose);
intentClose.setComponent(componentName);
views.setOnClickPendingIntent(R.id.notifClose, PendingIntent.getService(this, 0, intentClose, 0));
Intent intentActivity = new Intent(FullPlaybackActivity.actionReturnFull);
intentActivity.setClass(this,FullPlaybackActivity.class);
intentActivity.putExtra(FileSystemActivity.keyMusic,tracks);
Notification notification = new Notification();
notification.contentView = views;
notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
notification.contentIntent = PendingIntent.getActivity(this,0,intentActivity,0);
notification.icon = isPlaying ? R.drawable.status_icon_pause : R.drawable.status_icon_play;
return notification;
}