List of usage examples for android.widget RemoteViews setImageViewBitmap
public void setImageViewBitmap(int viewId, Bitmap bitmap)
From source file:com.firefly.sample.castcompanionlibrary.notification.VideoCastNotificationService.java
private RemoteViews build(MediaInfo info, Bitmap bitmap, boolean isPlaying, Class<?> targetActivity) throws CastException, TransientNetworkDisconnectionException, NoConnectionException { Bundle mediaWrapper = Utils.fromMediaInfo(mCastManager.getRemoteMediaInformation()); Intent contentIntent = null;//from w w w .ja v a 2s.c o m if (null == mTargetActivity) { mTargetActivity = VideoCastControllerActivity.class; } contentIntent = new Intent(this, mTargetActivity); contentIntent.putExtra("media", mediaWrapper); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(mTargetActivity); stackBuilder.addNextIntent(contentIntent); if (stackBuilder.getIntentCount() > 1) { stackBuilder.editIntentAt(1).putExtra("media", mediaWrapper); } // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(NOTIFICATION_ID, PendingIntent.FLAG_UPDATE_CURRENT); MediaMetadata mm = info.getMetadata(); RemoteViews rv = new RemoteViews(getPackageName(), R.layout.custom_notification); if (mIsIcsOrAbove) { addPendingIntents(rv, isPlaying, info); } if (null != bitmap) { rv.setImageViewBitmap(R.id.iconView, bitmap); } rv.setTextViewText(R.id.titleView, mm.getString(MediaMetadata.KEY_TITLE)); String castingTo = getResources().getString(R.string.casting_to_device, mCastManager.getDeviceName()); rv.setTextViewText(R.id.subTitleView, castingTo); mNotification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_stat_action_notification) .setContentIntent(resultPendingIntent).setContent(rv).setAutoCancel(false).setOngoing(true).build(); // to get around a bug in GB version, we add the following line // see https://code.google.com/p/android/issues/detail?id=30495 mNotification.contentView = rv; return rv; }
From source file:air.com.snagfilms.cast.chromecast.notifications.VideoCastNotificationService.java
private RemoteViews build(MediaInfo info, Bitmap bitmap, boolean isPlaying, Class<?> targetActivity) throws CastException, TransientNetworkDisconnectionException, NoConnectionException { Bundle mediaWrapper = Utils.fromMediaInfo(mCastManager.getRemoteMediaInformation()); Intent contentIntent = null;// w ww . j a v a 2s.c om if (null == mTargetActivity) { mTargetActivity = VideoPlayerActivity.class; } contentIntent = new Intent(this, mTargetActivity); contentIntent.putExtra("media", mediaWrapper); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(mTargetActivity); stackBuilder.addNextIntent(contentIntent); if (stackBuilder.getIntentCount() > 1) { stackBuilder.editIntentAt(1).putExtra("media", mediaWrapper); } // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(NOTIFICATION_ID, PendingIntent.FLAG_UPDATE_CURRENT); MediaMetadata mm = info.getMetadata(); RemoteViews rv = new RemoteViews(getPackageName(), R.layout.custom_notification); if (mIsIcsOrAbove) { addPendingIntents(rv, isPlaying, info); } if (null != bitmap) { rv.setImageViewBitmap(R.id.iconView, bitmap); } rv.setTextViewText(R.id.titleView, mm.getString(MediaMetadata.KEY_TITLE)); String castingTo = getResources().getString(R.string.casting_to_device, mCastManager.getDeviceName()); rv.setTextViewText(R.id.subTitleView, castingTo); mNotification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_stat_action_notification) .setContentIntent(resultPendingIntent).setContent(rv).setAutoCancel(false).setOngoing(true).build(); // to get around a bug in GB version, we add the following line // see https://code.google.com/p/android/issues/detail?id=30495 mNotification.contentView = rv; return rv; }
From source file:github.popeen.dsub.util.Notifications.java
private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean expanded, boolean playing, boolean remote, boolean isSingleFile, boolean shouldFastForward) { // Use the same text for the ticker and the expanded notification String title = song.getTitle(); String arist = song.getArtist(); String album = song.getAlbum(); // Set the album art. try {/*from ww w . j a v a 2 s.com*/ ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(context); Bitmap bitmap = null; if (imageLoader != null) { bitmap = imageLoader.getCachedImage(context, song, false); } if (bitmap == null) { // set default album art rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); } else { imageLoader.setNowPlayingSmall(bitmap); rv.setImageViewBitmap(R.id.notification_image, bitmap); } } catch (Exception x) { Log.w(TAG, "Failed to get notification cover art", x); rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); } // set the text for the notifications rv.setTextViewText(R.id.notification_title, title); rv.setTextViewText(R.id.notification_artist, arist); rv.setTextViewText(R.id.notification_album, album); boolean persistent = Util.getPreferences(context) .getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false); if (persistent) { if (expanded) { rv.setImageViewResource(R.id.control_pause, playing ? R.drawable.notification_pause : R.drawable.notification_start); if (shouldFastForward) { rv.setImageViewResource(R.id.control_previous, R.drawable.notification_rewind); rv.setImageViewResource(R.id.control_next, R.drawable.notification_fastforward); } else { rv.setImageViewResource(R.id.control_previous, R.drawable.notification_backward); rv.setImageViewResource(R.id.control_next, R.drawable.notification_forward); } } else { rv.setImageViewResource(R.id.control_previous, playing ? R.drawable.notification_pause : R.drawable.notification_start); if (shouldFastForward) { rv.setImageViewResource(R.id.control_pause, R.drawable.notification_fastforward); } else { rv.setImageViewResource(R.id.control_pause, R.drawable.notification_forward); } rv.setImageViewResource(R.id.control_next, R.drawable.notification_close); } } else if (shouldFastForward) { rv.setImageViewResource(R.id.control_previous, R.drawable.notification_rewind); rv.setImageViewResource(R.id.control_next, R.drawable.notification_fastforward); } else { // Necessary for switching back since it appears to re-use the same layout rv.setImageViewResource(R.id.control_previous, R.drawable.notification_backward); rv.setImageViewResource(R.id.control_next, R.drawable.notification_forward); } // Create actions for media buttons int previous = 0, pause = 0, next = 0, close = 0, rewind = 0, fastForward = 0; if (expanded) { pause = R.id.control_pause; if (shouldFastForward) { rewind = R.id.control_previous; fastForward = R.id.control_next; } else { previous = R.id.control_previous; next = R.id.control_next; } if (remote || persistent) { close = R.id.notification_close; rv.setViewVisibility(close, View.VISIBLE); } } else { if (persistent) { pause = R.id.control_previous; if (shouldFastForward) { fastForward = R.id.control_pause; } else { next = R.id.control_pause; } close = R.id.control_next; } else { if (shouldFastForward) { rewind = R.id.control_previous; fastForward = R.id.control_next; } else { previous = R.id.control_previous; next = R.id.control_next; } pause = R.id.control_pause; } } if (isSingleFile) { if (previous > 0) { rv.setViewVisibility(previous, View.GONE); previous = 0; } if (rewind > 0) { rv.setViewVisibility(rewind, View.GONE); rewind = 0; } if (next > 0) { rv.setViewVisibility(next, View.GONE); next = 0; } if (fastForward > 0) { rv.setViewVisibility(fastForward, View.GONE); fastForward = 0; } } PendingIntent pendingIntent; if (previous > 0) { Intent prevIntent = new Intent("KEYCODE_MEDIA_PREVIOUS"); prevIntent.setComponent(new ComponentName(context, DownloadService.class)); prevIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS)); pendingIntent = PendingIntent.getService(context, 0, prevIntent, 0); rv.setOnClickPendingIntent(previous, pendingIntent); } if (rewind > 0) { Intent rewindIntent = new Intent("KEYCODE_MEDIA_REWIND"); rewindIntent.setComponent(new ComponentName(context, DownloadService.class)); rewindIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_REWIND)); pendingIntent = PendingIntent.getService(context, 0, rewindIntent, 0); rv.setOnClickPendingIntent(rewind, pendingIntent); } if (pause > 0) { if (playing) { Intent pauseIntent = new Intent("KEYCODE_MEDIA_PLAY_PAUSE"); pauseIntent.setComponent(new ComponentName(context, DownloadService.class)); pauseIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE)); pendingIntent = PendingIntent.getService(context, 0, pauseIntent, 0); rv.setOnClickPendingIntent(pause, pendingIntent); } else { Intent prevIntent = new Intent("KEYCODE_MEDIA_START"); prevIntent.setComponent(new ComponentName(context, DownloadService.class)); prevIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY)); pendingIntent = PendingIntent.getService(context, 0, prevIntent, 0); rv.setOnClickPendingIntent(pause, pendingIntent); } } if (next > 0) { Intent nextIntent = new Intent("KEYCODE_MEDIA_NEXT"); nextIntent.setComponent(new ComponentName(context, DownloadService.class)); nextIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT)); pendingIntent = PendingIntent.getService(context, 0, nextIntent, 0); rv.setOnClickPendingIntent(next, pendingIntent); } if (fastForward > 0) { Intent fastForwardIntent = new Intent("KEYCODE_MEDIA_FAST_FORWARD"); fastForwardIntent.setComponent(new ComponentName(context, DownloadService.class)); fastForwardIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_FAST_FORWARD)); pendingIntent = PendingIntent.getService(context, 0, fastForwardIntent, 0); rv.setOnClickPendingIntent(fastForward, pendingIntent); } if (close > 0) { Intent prevIntent = new Intent("KEYCODE_MEDIA_STOP"); prevIntent.setComponent(new ComponentName(context, DownloadService.class)); prevIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_STOP)); pendingIntent = PendingIntent.getService(context, 0, prevIntent, 0); rv.setOnClickPendingIntent(close, pendingIntent); } }
From source file:com.google.sample.castcompanionlibrary.notification.VideoCastNotificationService.java
private RemoteViews build(MediaInfo info, Bitmap bitmap, boolean isPlaying) throws CastException, TransientNetworkDisconnectionException, NoConnectionException { if (mIsLollipopOrAbove) { buildForLollipopAndAbove(info, bitmap, isPlaying); return null; }// ww w. java 2 s .co m Bundle mediaWrapper = Utils.fromMediaInfo(mCastManager.getRemoteMediaInformation()); Intent contentIntent = new Intent(this, mTargetActivity); contentIntent.putExtra("media", mediaWrapper); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(mTargetActivity); stackBuilder.addNextIntent(contentIntent); if (stackBuilder.getIntentCount() > 1) { stackBuilder.editIntentAt(1).putExtra("media", mediaWrapper); } // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(NOTIFICATION_ID, PendingIntent.FLAG_UPDATE_CURRENT); MediaMetadata mm = info.getMetadata(); RemoteViews rv = new RemoteViews(getPackageName(), R.layout.custom_notification); if (mIsIcsOrAbove) { addPendingIntents(rv, isPlaying, info); } if (null != bitmap) { rv.setImageViewBitmap(R.id.iconView, bitmap); } else { bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.dummy_album_art); rv.setImageViewBitmap(R.id.iconView, bitmap); } rv.setTextViewText(R.id.titleView, mm.getString(MediaMetadata.KEY_TITLE)); String castingTo = getResources().getString(R.string.casting_to_device, mCastManager.getDeviceName()); rv.setTextViewText(R.id.subTitleView, castingTo); mNotification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_stat_action_notification) .setContentIntent(resultPendingIntent).setContent(rv).setAutoCancel(false).setOngoing(true).build(); // to get around a bug in GB version, we add the following line // see https://code.google.com/p/android/issues/detail?id=30495 mNotification.contentView = rv; return rv; }
From source file:com.mb.android.playbackmediator.notification.VideoCastNotificationService.java
private RemoteViews build(SessionInfoDto info, Bitmap bitmap, boolean isPlaying) throws CastException, TransientNetworkDisconnectionException, NoConnectionException { if (info.getNowPlayingItem() == null) { return null; }/* w w w .ja v a 2 s . c o m*/ if (mIsLollipopOrAbove) { buildForLollipopAndAbove(info, bitmap, isPlaying); return null; } Bundle mediaWrapper = Utils.fromMediaInfo(mCastManager.getRemoteMediaInformation()); mTargetActivity = RemoteControlActivity.class; Intent contentIntent = new Intent(this, mTargetActivity); contentIntent.putExtra("LAUNCHED_BY_NOTIFICATION", true); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(mTargetActivity); stackBuilder.addNextIntent(contentIntent); if (stackBuilder.getIntentCount() > 1) { stackBuilder.editIntentAt(1).putExtra("media", mediaWrapper); } // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(NOTIFICATION_ID, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews rv = new RemoteViews(getPackageName(), R.layout.custom_notification); if (mIsIcsOrAbove) { addPendingIntents(rv, isPlaying, info); } if (null != bitmap) { rv.setImageViewBitmap(R.id.iconView, bitmap); } rv.setTextViewText(R.id.titleView, info.getNowPlayingItem().getName()); String castingTo = getResources().getString(R.string.casting_to_device, mCastManager.getDeviceName()); rv.setTextViewText(R.id.subTitleView, castingTo); mNotification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_stat_action_notification) .setContentIntent(resultPendingIntent).setContent(rv).setAutoCancel(false).setOngoing(true).build(); // to get around a bug in GB version, we add the following line // see https://code.google.com/p/android/issues/detail?id=30495 mNotification.contentView = rv; return rv; }
From source file:org.chromium.chrome.browser.media.ui.NotificationMediaPlaybackControls.java
private void updateNotification() { if (mService == null) return;/*from w w w .j a v a 2 s . c o m*/ if (mMediaNotificationInfo == null) { // Notification was hidden before we could update it. assert mNotificationBuilder == null; return; } // Android doesn't badge the icons for RemoteViews automatically when // running the app under the Work profile. if (mNotificationIcon == null) { Drawable notificationIconDrawable = ApiCompatibilityUtils.getUserBadgedIcon(mContext, R.drawable.audio_playing); mNotificationIcon = drawableToBitmap(notificationIconDrawable); } if (mNotificationBuilder == null) { mNotificationBuilder = new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.audio_playing) .setAutoCancel(false).setLocalOnly(true) .setDeleteIntent(mService.getPendingIntent(ListenerService.ACTION_STOP)); } mNotificationBuilder.setOngoing(!mMediaNotificationInfo.isPaused); mNotificationBuilder.setContentIntent(createContentIntent()); RemoteViews contentView = createContentView(); contentView.setTextViewText(R.id.title, mMediaNotificationInfo.title); contentView.setTextViewText(R.id.status, getStatus()); if (mNotificationIcon != null) { contentView.setImageViewBitmap(R.id.icon, mNotificationIcon); } else { contentView.setImageViewResource(R.id.icon, R.drawable.audio_playing); } if (mMediaNotificationInfo.isPaused) { contentView.setImageViewResource(R.id.playpause, R.drawable.ic_vidcontrol_play); contentView.setContentDescription(R.id.playpause, mPlayDescription); contentView.setOnClickPendingIntent(R.id.playpause, mService.getPendingIntent(ListenerService.ACTION_PLAY)); } else { contentView.setImageViewResource(R.id.playpause, R.drawable.ic_vidcontrol_pause); contentView.setContentDescription(R.id.playpause, mPauseDescription); contentView.setOnClickPendingIntent(R.id.playpause, mService.getPendingIntent(ListenerService.ACTION_PAUSE)); } mNotificationBuilder.setContent(contentView); mNotificationBuilder.setVisibility(mMediaNotificationInfo.isPrivate ? NotificationCompat.VISIBILITY_PRIVATE : NotificationCompat.VISIBILITY_PUBLIC); if (mMediaSession == null) { mMediaSession = new MediaSessionCompat(mContext, mContext.getString(R.string.app_name), new ComponentName(mContext.getPackageName(), MediaButtonReceiver.class.getName()), null); mMediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS); mMediaSession.setCallback(mMediaSessionCallback); mMediaSession.setActive(true); } mMediaSession.setMetadata(createMetadata()); PlaybackStateCompat.Builder playbackStateBuilder = new PlaybackStateCompat.Builder() .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE); if (mMediaNotificationInfo.isPaused) { playbackStateBuilder.setState(PlaybackStateCompat.STATE_PAUSED, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f); } else { playbackStateBuilder.setState(PlaybackStateCompat.STATE_PLAYING, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f); } mMediaSession.setPlaybackState(playbackStateBuilder.build()); Notification notification = mNotificationBuilder.build(); // We keep the service as a foreground service while the media is playing. When it is not, // the service isn't stopped but is no longer in foreground, thus at a lower priority. // While the service is in foreground, the associated notification can't be swipped away. // Moving it back to background allows the user to remove the notification. if (mMediaNotificationInfo.isPaused) { mService.stopForeground(false /* removeNotification */); NotificationManagerCompat manager = NotificationManagerCompat.from(mContext); manager.notify(R.id.media_playback_notification, notification); } else { mService.startForeground(R.id.media_playback_notification, notification); } }
From source file:ru.org.sevn.audiobookplayer.AppService.java
private NotificationCompat.Builder makeNotify(Context ctx, String title, String text) { //Notification notification = new Notification(R.drawable.ic_launcher, null, System.currentTimeMillis()); NotificationCompat.Builder mBuilder = makeNotifyBuilder(ctx, title, text); RemoteViews notificationView = new RemoteViews(getPackageName(), R.layout.notification); notificationView.setTextViewText(R.id.tvTitle, title); notificationView.setTextViewText(R.id.textView1, "" + makeNotifyNumber() + " " + text); notificationView.setImageViewBitmap(R.id.imageView1, getLargeNotificationIcon()); mBuilder.setContent(notificationView); mBuilder.setContentIntent(makePendingNotificationIntent(makeNotificationIntent())); // notification.contentView = notificationView; // notification.contentIntent = makePendingNotificationIntent(makeNotificationIntent()); // notification.flags |= Notification.FLAG_NO_CLEAR; notificationView.setOnClickPendingIntent(R.id.btn_prev, makeActionPendingIntent(ACTION_PREV)); notificationView.setOnClickPendingIntent(R.id.btn_play, makeActionPendingIntent(ACTION_PLAY_PAUSE)); notificationView.setOnClickPendingIntent(R.id.btn_next, makeActionPendingIntent(ACTION_NEXT)); notificationView.setOnClickPendingIntent(R.id.btn_exit, makeActionPendingIntent(ACTION_EXIT)); return mBuilder; }
From source file:net.networksaremadeofstring.rhybudd.ZenossWidgetGraph.java
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) { if (settings == null) settings = PreferenceManager.getDefaultSharedPreferences(context); wContext = context;//from w w w . j a v a2s . co m Refresh(); handler = new Handler() { public void handleMessage(Message msg) { if (msg.what == 1) { Bundle Values = msg.getData(); final int N = appWidgetIds.length; RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.zenoss_widget_graph); //Intent intent = new Intent(context, rhestr.class); //PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); //Log.i("GraphWidget","Drawing Graph!"); for (int i = 0; i < N; i++) { int appWidgetId = appWidgetIds[i]; views.setImageViewBitmap(R.id.graphCanvas, RenderBarGraph(Values.getInt("CritCount"), Values.getInt("ErrCount"), Values.getInt("WarnCount"))); appWidgetManager.updateAppWidget(appWidgetId, views); } } } }; }
From source file:org.zoumbox.mh_dla_notifier.Receiver.java
protected void checkForWidgetsUpdate(Context context, Troll troll) { try {/*from w w w . j a v a 2 s.c om*/ AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); ComponentName componentName = new ComponentName(context, HomeScreenWidget.class); int[] appWidgetIds = widgetManager.getAppWidgetIds(componentName); if (appWidgetIds != null && appWidgetIds.length > 0) { // FIXME AThimel 14/02/14 Remove ASAP StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); String dlaText = Trolls.getWidgetDlaTextFunction(context).apply(troll); Bitmap blason = MhDlaNotifierUtils.loadBlasonForWidget(troll.getBlason(), context.getCacheDir()); for (int appWidgetId : appWidgetIds) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.home_screen_widget); views.setTextViewText(R.id.widgetDla, dlaText); if (blason == null) { views.setImageViewResource(R.id.widgetImage, R.drawable.trarnoll_square_transparent_128); } else { views.setImageViewBitmap(R.id.widgetImage, blason); } // Tell the AppWidgetManager to perform an update on the current app widget widgetManager.updateAppWidget(appWidgetId, views); } } } catch (Exception eee) { Log.e(TAG, "Unable to update widget(s)", eee); } }
From source file:org.physical_web.physicalweb.UriBeaconDiscoveryService.java
private void updateSummaryNotificationRemoteViewsFirstBeacon(String url, RemoteViews remoteViews) { MetadataResolver.UrlMetadata urlMetadata_firstBeacon = mUrlToUrlMetadata.get(url); if (urlMetadata_firstBeacon != null) { String title = mUrlToUrlMetadata.get(url).title; String description = mUrlToUrlMetadata.get(url).description; Bitmap icon = mUrlToUrlMetadata.get(url).icon; remoteViews.setImageViewBitmap(R.id.icon_firstBeacon, icon); remoteViews.setTextViewText(R.id.title_firstBeacon, title); remoteViews.setTextViewText(R.id.url_firstBeacon, url); remoteViews.setTextViewText(R.id.description_firstBeacon, description); // Recolor notifications to have light text for non-Lollipop devices if (!(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)) { remoteViews.setTextColor(R.id.title_firstBeacon, NON_LOLLIPOP_NOTIFICATION_TITLE_COLOR); remoteViews.setTextColor(R.id.url_firstBeacon, NON_LOLLIPOP_NOTIFICATION_URL_COLOR); remoteViews.setTextColor(R.id.description_firstBeacon, NON_LOLLIPOP_NOTIFICATION_SNIPPET_COLOR); }//from www. j a v a 2s . c o m // Create an intent that will open the browser to the beacon's url // if the user taps the notification PendingIntent pendingIntent = createNavigateToUrlPendingIntent(url); remoteViews.setOnClickPendingIntent(R.id.first_beacon_main_layout, pendingIntent); remoteViews.setViewVisibility(R.id.firstBeaconLayout, View.VISIBLE); } else { remoteViews.setViewVisibility(R.id.firstBeaconLayout, View.GONE); } }