List of usage examples for android.widget RemoteViews setTextViewText
public void setTextViewText(int viewId, CharSequence text)
From source file:com.kiandastream.musicplayer.MusicService.java
public void setListeners(RemoteViews view, String songname) { //listener 1/*w ww. j ava 2s. c om*/ view.setTextViewText(R.id.songname, songname); PendingIntent backword = PendingIntent.getService(this, 0, new Intent(MusicService.ACTION_REWIND), 0); view.setOnClickPendingIntent(R.id.backword, backword); //listener 2 if (mState == State.Playing) { PendingIntent playpause = PendingIntent.getService(this, 1, new Intent(MusicService.ACTION_PAUSE), 0); view.setOnClickPendingIntent(R.id.play, playpause); view.setImageViewResource(R.id.play, R.drawable.pause); } else { if (mState == State.Paused) { PendingIntent playpause = PendingIntent.getService(this, 1, new Intent(MusicService.ACTION_RESUME), 0); view.setOnClickPendingIntent(R.id.play, playpause); view.setImageViewResource(R.id.play, R.drawable.play); } } //listener 3 PendingIntent forward = PendingIntent.getService(this, 2, new Intent(MusicService.ACTION_NEXT), 0); view.setOnClickPendingIntent(R.id.forward, forward); //listener 4 PendingIntent close = PendingIntent.getService(this, 3, new Intent(MusicService.ACTION_STOP), 0); view.setOnClickPendingIntent(R.id.close, close); }
From source file:com.nd.android.u.square.service.MusicPlaybackService.java
Notification buildNotification(String text) { // Log.d("yulin", "buildNotification, musicName = " + musicName + ", mIsPause = " + mIsPause); NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder(this); mNotificationBuilder.setOngoing(true); mNotificationBuilder.setAutoCancel(false); mNotificationBuilder.setSmallIcon(R.drawable.ic_square_notification_music_play); mNotificationBuilder.setTicker(text); //Grab the notification layout. RemoteViews notificationView = new RemoteViews(getPackageName(), R.layout.square_notification_music_play); Intent stopServiceIntent = new Intent(ACTION_STOP); PendingIntent stopServicePendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, stopServiceIntent, 0);/* www . j av a 2 s. co m*/ //Set the notification content. notificationView.setTextViewText(R.id.notification_base_line_one, text); //Set the "Stop Service" pending intent. notificationView.setOnClickPendingIntent(R.id.notification_base_collapse, stopServicePendingIntent); //Set the album art. notificationView.setImageViewResource(R.id.notification_base_image, R.drawable.ic_square_music_default); //Attach the shrunken layout to the notification. mNotificationBuilder.setContent(notificationView); //Build the notification object and set its flags. Notification notification = mNotificationBuilder.build(); notification.flags = Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; return notification; }
From source file:github.daneren2005.dsub.util.Util.java
private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing) { // 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 w w w . j ava 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 rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); } else { 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); Pair<Integer, Integer> colors = getNotificationTextColors(context); if (colors.getFirst() != null) { rv.setTextColor(R.id.notification_title, colors.getFirst()); } if (colors.getSecond() != null) { rv.setTextColor(R.id.notification_artist, colors.getSecond()); } if (!playing) { rv.setImageViewResource(R.id.control_pause, R.drawable.notification_play); rv.setImageViewResource(R.id.control_previous, R.drawable.notification_stop); } // Create actions for media buttons PendingIntent pendingIntent; if (playing) { Intent prevIntent = new Intent("KEYCODE_MEDIA_PREVIOUS"); prevIntent.setComponent(new ComponentName(context, DownloadServiceImpl.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(R.id.control_previous, pendingIntent); } else { Intent prevIntent = new Intent("KEYCODE_MEDIA_STOP"); prevIntent.setComponent(new ComponentName(context, DownloadServiceImpl.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(R.id.control_previous, pendingIntent); } Intent pauseIntent = new Intent("KEYCODE_MEDIA_PLAY_PAUSE"); pauseIntent.setComponent(new ComponentName(context, DownloadServiceImpl.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(R.id.control_pause, pendingIntent); Intent nextIntent = new Intent("KEYCODE_MEDIA_NEXT"); nextIntent.setComponent(new ComponentName(context, DownloadServiceImpl.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(R.id.control_next, pendingIntent); }
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. *///from ww w . j a v a2s . 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; }
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 2 s .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:org.solovyev.android.calculator.widget.CalculatorWidget.java
private void updateWidget(@Nonnull Context context, @Nonnull AppWidgetManager manager, @Nonnull int[] widgetIds, boolean partially) { final EditorState editorState = editor.getState(); final DisplayState displayState = display.getState(); final Resources resources = context.getResources(); final SimpleTheme theme = App.getWidgetTheme().resolveThemeFor(App.getTheme()); for (int widgetId : widgetIds) { final RemoteViews views = new RemoteViews(context.getPackageName(), getLayout(manager, widgetId, resources, theme)); if (!partially || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { for (CppButton button : CppButton.values()) { final PendingIntent intent = intents.get(context, button); if (intent != null) { final int buttonId; if (button == CppButton.settings_widget) { // overriding default settings button behavior buttonId = CppButton.settings.id; } else { buttonId = button.id; }//from w w w .ja v a2s . c o m views.setOnClickPendingIntent(buttonId, intent); } } } updateEditorState(context, views, editorState, theme); updateDisplayState(context, views, displayState, theme); views.setTextViewText(R.id.cpp_button_multiplication, engine.getMultiplicationSign()); if (partially && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { manager.partiallyUpdateAppWidget(widgetId, views); } else { manager.updateAppWidget(widgetId, views); } } }
From source file:com.irccloud.android.Notifications.java
@SuppressLint("NewApi") private android.app.Notification buildNotification(String ticker, int bid, long[] eids, String title, String text, Spanned big_text, int count, Intent replyIntent, Spanned wear_text, String network, String auto_messages[]) { SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext()); NotificationCompat.Builder builder = new NotificationCompat.Builder( IRCCloudApplication.getInstance().getApplicationContext()) .setContentTitle(title + ((network != null) ? (" (" + network + ")") : "")) .setContentText(Html.fromHtml(text)).setAutoCancel(true).setTicker(ticker) .setWhen(eids[0] / 1000).setSmallIcon(R.drawable.ic_stat_notify) .setColor(IRCCloudApplication.getInstance().getApplicationContext().getResources() .getColor(R.color.dark_blue)) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setCategory(NotificationCompat.CATEGORY_MESSAGE) .setPriority(NotificationCompat.PRIORITY_HIGH).setOnlyAlertOnce(false); if (ticker != null && (System.currentTimeMillis() - prefs.getLong("lastNotificationTime", 0)) > 10000) { if (prefs.getBoolean("notify_vibrate", true)) builder.setDefaults(android.app.Notification.DEFAULT_VIBRATE); String ringtone = prefs.getString("notify_ringtone", "content://settings/system/notification_sound"); if (ringtone != null && ringtone.length() > 0) builder.setSound(Uri.parse(ringtone)); }/*from w ww.j a v a2 s. c o m*/ int led_color = Integer.parseInt(prefs.getString("notify_led_color", "1")); if (led_color == 1) { if (prefs.getBoolean("notify_vibrate", true)) builder.setDefaults( android.app.Notification.DEFAULT_LIGHTS | android.app.Notification.DEFAULT_VIBRATE); else builder.setDefaults(android.app.Notification.DEFAULT_LIGHTS); } else if (led_color == 2) { builder.setLights(0xFF0000FF, 500, 500); } SharedPreferences.Editor editor = prefs.edit(); editor.putLong("lastNotificationTime", System.currentTimeMillis()); editor.commit(); Intent i = new Intent(); i.setComponent(new ComponentName(IRCCloudApplication.getInstance().getApplicationContext().getPackageName(), "com.irccloud.android.MainActivity")); i.putExtra("bid", bid); i.setData(Uri.parse("bid://" + bid)); Intent dismiss = new Intent(IRCCloudApplication.getInstance().getApplicationContext().getResources() .getString(R.string.DISMISS_NOTIFICATION)); dismiss.setData(Uri.parse("irccloud-dismiss://" + bid)); dismiss.putExtra("bid", bid); dismiss.putExtra("eids", eids); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast( IRCCloudApplication.getInstance().getApplicationContext(), 0, dismiss, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent( PendingIntent.getActivity(IRCCloudApplication.getInstance().getApplicationContext(), 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setDeleteIntent(dismissPendingIntent); if (replyIntent != null) { WearableExtender extender = new WearableExtender(); PendingIntent replyPendingIntent = PendingIntent.getService( IRCCloudApplication.getInstance().getApplicationContext(), bid + 1, replyIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT); extender.addAction( new NotificationCompat.Action.Builder(R.drawable.ic_reply, "Reply", replyPendingIntent) .addRemoteInput( new RemoteInput.Builder("extra_reply").setLabel("Reply to " + title).build()) .build()); if (count > 1 && wear_text != null) extender.addPage( new NotificationCompat.Builder(IRCCloudApplication.getInstance().getApplicationContext()) .setContentText(wear_text).extend(new WearableExtender().setStartScrollBottom(true)) .build()); NotificationCompat.CarExtender.UnreadConversation.Builder unreadConvBuilder = new NotificationCompat.CarExtender.UnreadConversation.Builder( title + ((network != null) ? (" (" + network + ")") : "")) .setReadPendingIntent(dismissPendingIntent).setReplyAction(replyPendingIntent, new RemoteInput.Builder("extra_reply").setLabel("Reply to " + title).build()); if (auto_messages != null) { for (String m : auto_messages) { if (m != null && m.length() > 0) { unreadConvBuilder.addMessage(m); } } } else { unreadConvBuilder.addMessage(text); } unreadConvBuilder.setLatestTimestamp(eids[count - 1] / 1000); builder.extend(extender) .extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConvBuilder.build())); } if (replyIntent != null && prefs.getBoolean("notify_quickreply", true)) { i = new Intent(IRCCloudApplication.getInstance().getApplicationContext(), QuickReplyActivity.class); i.setData(Uri.parse("irccloud-bid://" + bid)); i.putExtras(replyIntent); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent quickReplyIntent = PendingIntent.getActivity( IRCCloudApplication.getInstance().getApplicationContext(), 0, i, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(R.drawable.ic_action_reply, "Quick Reply", quickReplyIntent); } android.app.Notification notification = builder.build(); RemoteViews contentView = new RemoteViews( IRCCloudApplication.getInstance().getApplicationContext().getPackageName(), R.layout.notification); contentView.setTextViewText(R.id.title, title + " (" + network + ")"); contentView.setTextViewText(R.id.text, (count == 1) ? Html.fromHtml(text) : (count + " unread highlights.")); contentView.setLong(R.id.time, "setTime", eids[0] / 1000); notification.contentView = contentView; if (Build.VERSION.SDK_INT >= 16 && big_text != null) { RemoteViews bigContentView = new RemoteViews( IRCCloudApplication.getInstance().getApplicationContext().getPackageName(), R.layout.notification_expanded); bigContentView.setTextViewText(R.id.title, title + (!title.equals(network) ? (" (" + network + ")") : "")); bigContentView.setTextViewText(R.id.text, big_text); bigContentView.setLong(R.id.time, "setTime", eids[0] / 1000); if (count > 3) { bigContentView.setViewVisibility(R.id.more, View.VISIBLE); bigContentView.setTextViewText(R.id.more, "+" + (count - 3) + " more"); } else { bigContentView.setViewVisibility(R.id.more, View.GONE); } if (replyIntent != null && prefs.getBoolean("notify_quickreply", true)) { bigContentView.setViewVisibility(R.id.actions, View.VISIBLE); bigContentView.setViewVisibility(R.id.action_divider, View.VISIBLE); i = new Intent(IRCCloudApplication.getInstance().getApplicationContext(), QuickReplyActivity.class); i.setData(Uri.parse("irccloud-bid://" + bid)); i.putExtras(replyIntent); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent quickReplyIntent = PendingIntent.getActivity( IRCCloudApplication.getInstance().getApplicationContext(), 0, i, PendingIntent.FLAG_UPDATE_CURRENT); bigContentView.setOnClickPendingIntent(R.id.action_reply, quickReplyIntent); } notification.bigContentView = bigContentView; } return notification; }
From source file:net.naonedbus.appwidget.HoraireWidgetProvider.java
/** * Prparer le widget avec les horaires.//from ww w . j a va 2 s.c o m * * @param views * @param favori */ protected void prepareWidgetViewHoraires(final Context context, final RemoteViews views, final Favori favori, final List<Horaire> nextHoraires) { final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context); CharSequence content = ""; if (nextHoraires.size() > 0) { // Programmer si besoin l'alarme scheduleUpdate(context, nextHoraires.get(0).getHoraire().getMillis()); for (int i = 0; i < nextHoraires.size(); i++) { final Horaire horaire = nextHoraires.get(i); content = TextUtils.concat(content, FormatUtils.formatTimeAmPm(context, timeFormat.format(horaire.getHoraire().toDate()))); if (i < nextHoraires.size() - 1) { content = TextUtils.concat(content, " \u2022 "); } } } else { content = context.getString(R.string.msg_aucun_depart_24h); } views.setTextViewText(R.id.itemTime, content); views.setViewVisibility(R.id.widgetProgress, View.GONE); }
From source file:org.videolan.vlc.MediaService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void showNotification() { try {/*from w ww. ja v a2 s . 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, mIsVout ? MediaPlayerActivity.class : 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:au.com.wallaceit.reddinator.SubredditSelectActivity.java
private void updateFeedAndFinish() { if (widgetFirstTimeSetup) { finishWidgetSetup();/* ww w . j a v a 2 s . c o m*/ return; } if (mAppWidgetId != 0) { // refresh widget and close activity (NOTE: put in function) AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(SubredditSelectActivity.this); RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget); views.setTextViewText(R.id.subreddittxt, global.getSubredditManager().getCurrentFeedName(mAppWidgetId)); views.setViewVisibility(R.id.srloader, View.VISIBLE); views.setViewVisibility(R.id.erroricon, View.INVISIBLE); // bypass cache if service not loaded global.setBypassCache(true); appWidgetManager.partiallyUpdateAppWidget(mAppWidgetId, views); appWidgetManager.notifyAppWidgetViewDataChanged(mAppWidgetId, R.id.listview); } else { Intent intent = new Intent(); intent.putExtra("themeupdate", needsThemeUpdate); setResult(2, intent); // update feed prefs + reload feed } finish(); }