Example usage for android.widget RemoteViews RemoteViews

List of usage examples for android.widget RemoteViews RemoteViews

Introduction

In this page you can find the example usage for android.widget RemoteViews RemoteViews.

Prototype

public RemoteViews(RemoteViews landscape, RemoteViews portrait) 

Source Link

Document

Create a new RemoteViews object that will inflate as the specified landspace or portrait RemoteViews, depending on the current configuration.

Usage

From source file:au.com.wallaceit.reddinator.Rservice.java

private void hideWidgetLoader(boolean goToTopOfList, boolean showError) {
    AppWidgetManager mgr = AppWidgetManager.getInstance(mContext);
    // get theme layout id
    int layout = 1;
    switch (Integer.valueOf(mSharedPreferences.getString("widgetthemepref", "1"))) {
    case 1:/*  w w  w.j  a  va 2 s .  co  m*/
        layout = R.layout.widgetmain;
        break;
    case 2:
        layout = R.layout.widgetdark;
        break;
    case 3:
        layout = R.layout.widgetholo;
        break;
    case 4:
        layout = R.layout.widgetdarkholo;
        break;
    case 5:
        layout = R.layout.widgettrans;
        break;
    }
    RemoteViews views = new RemoteViews(mContext.getPackageName(), layout);
    views.setViewVisibility(R.id.srloader, View.INVISIBLE);
    // go to the top of the list view
    if (goToTopOfList) {
        views.setScrollPosition(R.id.listview, 0);
    }
    if (showError) {
        views.setViewVisibility(R.id.erroricon, View.VISIBLE);
    }
    mgr.partiallyUpdateAppWidget(appWidgetId, views);
}

From source file:com.andreadec.musicplayer.MusicService.java

private void updateNotificationMessage() {
    /* Update remote control client */
    if (Build.VERSION.SDK_INT >= 14) {
        if (currentPlayingItem == null) {
            remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
        } else {//  w  w w .ja  v  a 2 s  .c o m
            if (isPlaying()) {
                remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
            } else {
                remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
            }
            RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
            metadataEditor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, currentPlayingItem.getTitle());
            metadataEditor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, currentPlayingItem.getArtist());
            metadataEditor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST,
                    currentPlayingItem.getArtist());
            metadataEditor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, getDuration());
            if (currentPlayingItem.hasImage()) {
                metadataEditor.putBitmap(METADATA_KEY_ARTWORK, currentPlayingItem.getImage());
            } else {
                metadataEditor.putBitmap(METADATA_KEY_ARTWORK, icon.copy(icon.getConfig(), false));
            }
            metadataEditor.apply();
        }
    }

    /* Update notification */
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder.setSmallIcon(R.drawable.audio_white);
    //notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    notificationBuilder.setOngoing(true);

    int playPauseIcon = isPlaying() ? R.drawable.pause : R.drawable.play;
    //int playPauseString = isPlaying() ? R.string.pause : R.string.play;
    notificationBuilder.setContentIntent(pendingIntent);

    String notificationMessage = "";
    if (currentPlayingItem == null) {
        notificationMessage = getResources().getString(R.string.noSong);
    } else {
        if (currentPlayingItem.getArtist() != null && !currentPlayingItem.getArtist().equals(""))
            notificationMessage = currentPlayingItem.getArtist() + " - ";
        notificationMessage += currentPlayingItem.getTitle();
    }

    /*notificationBuilder.addAction(R.drawable.previous, getResources().getString(R.string.previous), previousPendingIntent);
    notificationBuilder.addAction(playPauseIcon, getResources().getString(playPauseString), playpausePendingIntent);
    notificationBuilder.addAction(R.drawable.next, getResources().getString(R.string.next), nextPendingIntent);*/
    notificationBuilder.setContentTitle(getResources().getString(R.string.app_name));
    notificationBuilder.setContentText(notificationMessage);

    notification = notificationBuilder.build();

    RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.layout_notification);

    if (currentPlayingItem == null) {
        notificationLayout.setTextViewText(R.id.textViewArtist, getString(R.string.app_name));
        notificationLayout.setTextViewText(R.id.textViewTitle, getString(R.string.noSong));
        notificationLayout.setImageViewBitmap(R.id.imageViewNotification,
                BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    } else {
        notificationLayout.setTextViewText(R.id.textViewArtist, currentPlayingItem.getArtist());
        notificationLayout.setTextViewText(R.id.textViewTitle, currentPlayingItem.getTitle());
        Bitmap image = currentPlayingItem.getImage();
        if (image != null) {
            notificationLayout.setImageViewBitmap(R.id.imageViewNotification, image);
        } else {
            notificationLayout.setImageViewBitmap(R.id.imageViewNotification,
                    BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
        }
    }
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationQuit, quitPendingIntent);
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationPrevious, previousPendingIntent);
    notificationLayout.setImageViewResource(R.id.buttonNotificationPlayPause, playPauseIcon);
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationPlayPause, playpausePendingIntent);
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationNext, nextPendingIntent);
    notification.bigContentView = notificationLayout;

    notificationManager.notify(Constants.NOTIFICATION_MAIN, notification);
}

From source file:com.chen.mail.utils.NotificationActionUtils.java

public static Notification createUndoNotification(final Context context,
        final NotificationAction notificationAction, final int notificationId) {
    LogUtils.i(LOG_TAG, "createUndoNotification for %s", notificationAction.getNotificationActionType());

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

    builder.setSmallIcon(R.drawable.stat_notify_email);
    builder.setWhen(notificationAction.getWhen());

    final RemoteViews undoView = new RemoteViews(context.getPackageName(), R.layout.undo_notification);
    undoView.setTextViewText(R.id.description_text, context.getString(notificationAction.getActionTextResId()));

    final String packageName = context.getPackageName();

    final Intent clickIntent = new Intent(NotificationActionIntentService.ACTION_UNDO);
    clickIntent.setPackage(packageName);
    putNotificationActionExtra(clickIntent, notificationAction);
    final PendingIntent clickPendingIntent = PendingIntent.getService(context, notificationId, clickIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    undoView.setOnClickPendingIntent(R.id.status_bar_latest_event_content, clickPendingIntent);

    builder.setContent(undoView);//  ww w.  j  a  v  a  2 s . co m

    // When the notification is cleared, we perform the destructive action
    final Intent deleteIntent = new Intent(NotificationActionIntentService.ACTION_DESTRUCT);
    deleteIntent.setPackage(packageName);
    putNotificationActionExtra(deleteIntent, notificationAction);
    final PendingIntent deletePendingIntent = PendingIntent.getService(context, notificationId, deleteIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setDeleteIntent(deletePendingIntent);

    final Notification notification = builder.build();

    return notification;
}

From source file:com.dmbstream.android.util.Util.java

public static void showPlayingNotification(final Context context, final DownloadServiceImpl downloadService,
        Handler handler, Track song) {

    // Use the same text for the ticker and the expanded notification
    String title = song.title;/*from ww w.  j ava2s.  c om*/
    String text = song.artist;

    // Set the icon, scrolling text and timestamp
    final Notification notification = new Notification(R.drawable.notify_playing, title,
            System.currentTimeMillis());
    notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;

    RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.partial_notification);

    // set the text for the notifications
    contentView.setTextViewText(R.id.notification_title, title);
    contentView.setTextViewText(R.id.notification_artist, text);

    Pair<Integer, Integer> colors = getNotificationTextColors(context);
    if (colors.getFirst() != null) {
        contentView.setTextColor(R.id.notification_title, colors.getFirst());
    }
    if (colors.getSecond() != null) {
        contentView.setTextColor(R.id.notification_artist, colors.getSecond());
    }

    notification.contentView = contentView;

    // Send them to the main menu when if they click the notification
    // TODO: Send them to the concert, playlist, compilation details or chat page?
    Intent notificationIntent = new Intent(context, MainMenuActivity.class);
    notification.contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    // Send the notification and put the service in the foreground.
    handler.post(new Runnable() {
        @Override
        public void run() {
            startForeground(downloadService, Constants.NOTIFICATION_ID_PLAYING, notification);
        }
    });

    // Update widget
    DmbstreamAppWidgetProvider.getInstance().notifyChange(context, downloadService, true);
}

From source file:com.darshancomputing.BatteryIndicatorPro.BatteryInfoService.java

private void prepareNotification() {
    mainNotificationTopLine = lineFor(SettingsActivity.KEY_TOP_LINE);
    mainNotificationBottomLine = lineFor(SettingsActivity.KEY_BOTTOM_LINE);

    mainNotificationB.setSmallIcon(iconFor(info.percent)).setOngoing(true).setWhen(0).setShowWhen(false)
            .setContentIntent(currentInfoPendingIntent)
            .setPriority(Integer.valueOf(settings.getString(SettingsActivity.KEY_MAIN_NOTIFICATION_PRIORITY,
                    str.default_main_notification_priority)))
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC);

    if (settings.getBoolean(SettingsActivity.KEY_USE_SYSTEM_NOTIFICATION_LAYOUT,
            res.getBoolean(R.bool.default_use_system_notification_layout))) {
        mainNotificationB.setContentTitle(mainNotificationTopLine).setContentText(mainNotificationBottomLine);

        needSetContentAgain = false;/*from  ww  w .j  a  va 2s. c  om*/
    } else {
        String icon_area = settings.getString(SettingsActivity.KEY_ICON_AREA,
                res.getString(R.string.default_icon_area_content));

        int layout_id = R.layout.main_notification;
        if (icon_area.equals("percentage_first"))
            layout_id = R.layout.main_notification_percentage_first;

        notificationRV = new RemoteViews(getPackageName(), layout_id);

        if (icon_area.equals("percentage")) {
            notificationRV.setViewVisibility(R.id.percent, View.VISIBLE);
            notificationRV.setViewVisibility(R.id.battery, View.GONE);
        } else if (icon_area.equals("graphic")) {
            notificationRV.setViewVisibility(R.id.percent, View.GONE);
            notificationRV.setViewVisibility(R.id.battery, View.VISIBLE);
        }

        notificationRV.setImageViewBitmap(R.id.battery, bl.getBitmap());
        bl.setLevel(info.percent);

        notificationRV.setTextViewText(R.id.percent, "" + info.percent + str.percent_symbol);
        notificationRV.setTextViewText(R.id.top_line, android.text.Html.fromHtml(mainNotificationTopLine));
        notificationRV.setTextViewText(R.id.bottom_line, mainNotificationBottomLine);

        int color;
        color = colorFor(SettingsActivity.KEY_NOTIFICATION_PERCENTAGE_TEXT_COLOR,
                SettingsActivity.KEY_CUSTOM_PERCENTAGE_TEXT_COLOR);
        if (color != 0)
            notificationRV.setTextColor(R.id.percent, color);
        color = colorFor(SettingsActivity.KEY_NOTIFICATION_TOP_LINE_COLOR,
                SettingsActivity.KEY_CUSTOM_TOP_LINE_COLOR);
        if (color != 0)
            notificationRV.setTextColor(R.id.top_line, color);
        color = colorFor(SettingsActivity.KEY_NOTIFICATION_BOTTOM_LINE_COLOR,
                SettingsActivity.KEY_CUSTOM_BOTTOM_LINE_COLOR);
        if (color != 0)
            notificationRV.setTextColor(R.id.bottom_line, color);

        boolean default_show_box = res.getBoolean(R.bool.default_show_box_around_icon_area);
        boolean show_box = settings.getBoolean(SettingsActivity.KEY_SHOW_BOX_AROUND_ICON_AREA,
                default_show_box);

        if (show_box) {
            color = res.getColor(R.color.notification_box_default_color);
            if (!icon_area.equals("battery_first"))
                notificationRV.setInt(R.id.percent, "setBackgroundColor", color);
            if (!icon_area.equals("percentage_first"))
                notificationRV.setInt(R.id.battery, "setBackgroundColor", color);
        }

        if (android.os.Build.VERSION.SDK_INT < 11)
            needSetContentAgain = true;

        mainNotificationB.setContent(notificationRV);
    }
}

From source file:net.tac42.subtails.util.Util.java

public static void showPlayingNotification(final Context context, final DownloadServiceImpl downloadService,
        Handler handler, MusicDirectory.Entry song) {

    // Use the same text for the ticker and the expanded notification
    String title = song.getTitle();
    String text = song.getArtist();

    // Set the icon, scrolling text and timestamp
    final Notification notification = new Notification(R.drawable.stat_notify_playing, title,
            System.currentTimeMillis());
    notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;

    RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.notification);

    // Set the album art.
    try {/*from w w  w. ja v a 2  s . co m*/
        int size = context.getResources().getDrawable(R.drawable.unknown_album).getIntrinsicHeight();
        Bitmap bitmap = FileUtil.getAlbumArtBitmap(context, song, size);
        if (bitmap == null) {
            // set default album art
            contentView.setImageViewResource(R.id.notification_image, R.drawable.unknown_album);
        } else {
            contentView.setImageViewBitmap(R.id.notification_image, bitmap);
        }
    } catch (Exception x) {
        Log.w(TAG, "Failed to get notification cover art", x);
        contentView.setImageViewResource(R.id.notification_image, R.drawable.unknown_album);
    }

    // set the text for the notifications
    contentView.setTextViewText(R.id.notification_title, title);
    contentView.setTextViewText(R.id.notification_artist, text);

    Pair<Integer, Integer> colors = getNotificationTextColors(context);
    if (colors.getFirst() != null) {
        contentView.setTextColor(R.id.notification_title, colors.getFirst());
    }
    if (colors.getSecond() != null) {
        contentView.setTextColor(R.id.notification_artist, colors.getSecond());
    }

    notification.contentView = contentView;

    Intent notificationIntent = new Intent(context, DownloadActivity.class);
    notification.contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    // Send the notification and put the service in the foreground.
    handler.post(new Runnable() {
        @Override
        public void run() {
            startForeground(downloadService, Constants.NOTIFICATION_ID_PLAYING, notification);
        }
    });

    // Update widget
    SubtailsAppWidgetProvider.getInstance().notifyChange(context, downloadService, true);
}

From source file:com.sean.takeastand.alarmprocess.AlarmService.java

private void sendNotification() {
    NotificationManager notificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);
    PendingIntent[] pendingIntents = makeNotificationIntents();
    RemoteViews rvRibbon = new RemoteViews(getPackageName(), R.layout.stand_notification);
    rvRibbon.setOnClickPendingIntent(R.id.btnStood, pendingIntents[1]);
    notificationClockTime = Utils.getFormattedCalendarTime(Calendar.getInstance(), this);
    rvRibbon.setTextViewText(R.id.notificationTimeStamp, notificationClockTime);
    NotificationCompat.Builder alarmNotificationBuilder = new NotificationCompat.Builder(this);
    alarmNotificationBuilder.setContent(rvRibbon).setContentIntent(pendingIntents[0]).setAutoCancel(false)
            .setTicker(getString(R.string.stand_up_time_low)).setSmallIcon(R.drawable.ic_notification_small)
            .setContentTitle("Take A Stand ").setContentText(
                    "Mark Stood")
            .extend(new NotificationCompat.WearableExtender().addAction(
                    new NotificationCompat.Action.Builder(R.drawable.ic_action_done, "Stood", pendingIntents[2])
                            .build())/*from   www  .  j a  va2  s. com*/
                    .setContentAction(0).setHintHideIcon(true)
    //                    .setBackground(BitmapFactory.decodeResource(getResources(), R.drawable.alarm_schedule_passed))
    );

    //Purpose of below is to figure out what type of user alert to give with the notification
    //If scheduled, check settings for that schedule
    //If unscheduled, check user defaults
    if (mCurrentAlarmSchedule != null) {
        boolean[] alertType = mCurrentAlarmSchedule.getAlertType();
        if ((alertType[0])) {
            alarmNotificationBuilder.setLights(238154000, 1000, 4000);
        }
        if (alertType[1]) {
            alarmNotificationBuilder.setVibrate(mVibrationPattern);
            AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            if (audioManager.getMode() == AudioManager.RINGER_MODE_SILENT && Utils.getVibrateOverride(this)) {
                Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                v.vibrate(mVibrationPattern, -1);
            }
        }
        if (alertType[2]) {
            Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            alarmNotificationBuilder.setSound(soundUri);
        }
    } else {
        boolean[] alertType = Utils.getDefaultAlertType(this);
        if ((alertType[0])) {
            alarmNotificationBuilder.setLights(238154000, 1000, 4000);
        }
        if (alertType[1]) {
            alarmNotificationBuilder.setVibrate(mVibrationPattern);
            AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            if (audioManager.getMode() == AudioManager.RINGER_MODE_SILENT && Utils.getVibrateOverride(this)) {
                Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                v.vibrate(mVibrationPattern, -1);
            }
        }
        if (alertType[2]) {
            Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            alarmNotificationBuilder.setSound(soundUri);
        }
    }
    Notification alarmNotification = alarmNotificationBuilder.build();
    notificationManager.notify(R.integer.AlarmNotificationID, alarmNotification);

    if (getSharedPreferences(Constants.USER_SHARED_PREFERENCES, 0).getBoolean(Constants.STANDDTECTORTM_ENABLED,
            false)) {
        Intent standSensorIntent = new Intent(this, StandDtectorTM.class);
        standSensorIntent.setAction(com.heckbot.standdtector.Constants.STANDDTECTOR_START);
        standSensorIntent.putExtra("MILLISECONDS", (long) 60000);

        standSensorIntent.putExtra("pendingIntent", pendingIntents[1]);

        startService(standSensorIntent);
    }
}

From source file:org.videolan.vlc.AudioService.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void showNotification() {
    try {//from  w  w w  . j  a v a  2s . c  o m
        Bitmap cover = AudioUtil.getCover(this, mCurrentMedia, 64);
        String title = mCurrentMedia.getTitle();
        String artist = mCurrentMedia.getArtist();
        String album = mCurrentMedia.getAlbum();
        Notification notification;

        // add notification to status bar
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_stat_vlc).setTicker(title + " - " + artist).setAutoCancel(false)
                .setOngoing(true);

        Intent notificationIntent = new Intent(this, AudioPlayerActivity.class);
        notificationIntent.setAction(Intent.ACTION_MAIN);
        notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        notificationIntent.putExtra(START_FROM_NOTIFICATION, true);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        if (Util.isJellyBeanOrLater()) {
            Intent iBackward = new Intent(ACTION_REMOTE_BACKWARD);
            Intent iPlay = new Intent(ACTION_REMOTE_PLAYPAUSE);
            Intent iForward = new Intent(ACTION_REMOTE_FORWARD);
            Intent iStop = new Intent(ACTION_REMOTE_STOP);
            PendingIntent piBackward = PendingIntent.getBroadcast(this, 0, iBackward,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            PendingIntent piPlay = PendingIntent.getBroadcast(this, 0, iPlay,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            PendingIntent piForward = PendingIntent.getBroadcast(this, 0, iForward,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            PendingIntent piStop = PendingIntent.getBroadcast(this, 0, iStop,
                    PendingIntent.FLAG_UPDATE_CURRENT);

            RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification);
            if (cover != null)
                view.setImageViewBitmap(R.id.cover, cover);
            view.setTextViewText(R.id.songName, title);
            view.setTextViewText(R.id.artist, artist);
            view.setImageViewResource(R.id.play_pause,
                    mLibVLC.isPlaying() ? R.drawable.ic_pause : R.drawable.ic_play);
            view.setOnClickPendingIntent(R.id.play_pause, piPlay);
            view.setOnClickPendingIntent(R.id.forward, piForward);
            view.setOnClickPendingIntent(R.id.stop, piStop);
            view.setOnClickPendingIntent(R.id.content, pendingIntent);

            RemoteViews view_expanded = new RemoteViews(getPackageName(), R.layout.notification_expanded);
            if (cover != null)
                view_expanded.setImageViewBitmap(R.id.cover, cover);
            view_expanded.setTextViewText(R.id.songName, title);
            view_expanded.setTextViewText(R.id.artist, artist);
            view_expanded.setTextViewText(R.id.album, album);
            view_expanded.setImageViewResource(R.id.play_pause,
                    mLibVLC.isPlaying() ? R.drawable.ic_pause : R.drawable.ic_play);
            view_expanded.setOnClickPendingIntent(R.id.backward, piBackward);
            view_expanded.setOnClickPendingIntent(R.id.play_pause, piPlay);
            view_expanded.setOnClickPendingIntent(R.id.forward, piForward);
            view_expanded.setOnClickPendingIntent(R.id.stop, piStop);
            view_expanded.setOnClickPendingIntent(R.id.content, pendingIntent);

            notification = builder.build();
            notification.contentView = view;
            notification.bigContentView = view_expanded;
        } else {
            builder.setLargeIcon(cover).setContentTitle(title)
                    .setContentText(Util.isJellyBeanOrLater() ? artist : mCurrentMedia.getSubtitle())
                    .setContentInfo(album).setContentIntent(pendingIntent);
            notification = builder.build();
        }

        startForeground(3, notification);
    } catch (NoSuchMethodError e) {
        // Compat library is wrong on 3.2
        // http://code.google.com/p/android/issues/detail?id=36359
        // http://code.google.com/p/android/issues/detail?id=36502
    }
}

From source file:com.namelessdev.mpdroid.NotificationService.java

/**
 * This generates the collapsed notification from base.
 *
 * @return The collapsed notification resources for RemoteViews.
 *///from  w  ww .  j ava2  s  .  co  m
private NotificationCompat.Builder buildNewCollapsedNotification() {
    final RemoteViews resultView = buildBaseNotification(
            new RemoteViews(getPackageName(), R.layout.notification));
    return buildStaticCollapsedNotification().setContent(resultView);
}

From source file:com.namelessdev.mpdroid.NotificationService.java

/**
 * buildExpandedNotification builds upon the collapsed notification resources to create
 * the resources necessary for the expanded notification RemoteViews.
 *
 * @return The expanded notification RemoteViews.
 *//*w  w w  .ja  v  a 2  s  .  c  o m*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private RemoteViews buildExpandedNotification() {
    final RemoteViews resultView;

    if (mNotification == null || mNotification.bigContentView == null) {
        resultView = new RemoteViews(getPackageName(), R.layout.notification_big);
    } else {
        resultView = mNotification.bigContentView;
    }

    buildBaseNotification(resultView);

    /** When streaming, move things down (hopefully, very) temporarily. */
    if (mediaPlayerServiceIsBuffering) {
        resultView.setTextViewText(R.id.notificationAlbum, mCurrentMusic.getArtist());
    } else {
        resultView.setTextViewText(R.id.notificationAlbum, mCurrentMusic.getAlbum());
    }

    resultView.setOnClickPendingIntent(R.id.notificationPrev, notificationPrevious);

    return resultView;
}