List of usage examples for android.widget RemoteViews setTextViewText
public void setTextViewText(int viewId, CharSequence text)
From source file:com.audiokernel.euphonyrmt.service.NotificationHandler.java
/** * Update the collapsed notification view for a "buffering" play state. * * @param resultView The notification view to edit. * @param trackTitle The current track title. *//* w ww . java 2s .c o m*/ private void updateBufferingContent(final RemoteViews resultView, final CharSequence trackTitle) { resultView.setViewVisibility(R.id.notificationClose, View.GONE); resultView.setTextViewText(R.id.notificationTitle, mServiceContext.getString(R.string.buffering)); resultView.setTextViewText(R.id.notificationArtist, trackTitle); }
From source file:free.yhc.netmbuddy.model.NotiManager.java
private Notification buildNotificationICS(NotiType ntype, CharSequence videoTitle) { RemoteViews rv = new RemoteViews(Utils.getAppContext().getPackageName(), R.layout.player_notification); NotificationCompat.Builder nbldr = new NotificationCompat.Builder(Utils.getAppContext()); rv.setTextViewText(R.id.title, videoTitle); Intent intent = new Intent(Utils.getAppContext(), NotiManager.NotiIntentReceiver.class); intent.setAction(NOTI_INTENT_ACTION); intent.putExtra("type", ntype.name()); PendingIntent pi = PendingIntent.getBroadcast(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setImageViewResource(R.id.action, ntype.getIcon()); rv.setOnClickPendingIntent(R.id.action, pi); intent = new Intent(Utils.getAppContext(), NotiManager.NotiIntentReceiver.class); intent.setAction(NOTI_INTENT_STOP_PLAYER); pi = PendingIntent.getBroadcast(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setImageViewResource(R.id.stop, R.drawable.ic_media_stop); rv.setOnClickPendingIntent(R.id.stop, pi); intent = new Intent(Utils.getAppContext(), NotiManager.NotiIntentReceiver.class); intent.setAction(NOTI_INTENT_DELETE); PendingIntent piDelete = PendingIntent.getBroadcast(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); intent = new Intent(Utils.getAppContext(), YTMPActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent piContent = PendingIntent.getActivity(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); nbldr.setContent(rv).setContentIntent(piContent).setDeleteIntent(piDelete).setAutoCancel(true) .setSmallIcon(ntype.getIcon()).setTicker(null); return nbldr.build(); }
From source file:com.gaze.webpaser.StackWidgetService.java
public RemoteViews getViewAt(int position) { Log.i(LOG_TAG, "getViewAt " + position); // position will always range from 0 to getCount() - 1. // We construct a remote views item based on our widget item xml file, // and set the // text based on the position. RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.item_widget); rv.setTextViewText(R.id.textView_title, mlist.get(position).getTitle()); String time = Util.getFormatTime(mlist.get(position).getTime()); rv.setTextViewText(R.id.textView3_time, time); // Next, we set a fill-intent which will be used to fill-in the pending // intent template // which is set on the collection view in StackWidgetProvider. Bundle extras = new Bundle(); extras.putInt(StackWidgetProvider.EXTRA_ITEM, position); Intent fillInIntent = new Intent(); fillInIntent.putExtras(extras);/*from w w w. jav a 2 s. c o m*/ rv.setOnClickFillInIntent(R.id.widget1, fillInIntent); // You can do heaving lifting in here, synchronously. For example, if // you need to // process an image, fetch something from the network, etc., it is ok to // do it here, // synchronously. A loading view will show up in lieu of the actual // contents in the // interim. // try { // System.out.println("Loading view " + position); // Thread.sleep(500); // } catch (InterruptedException e) { // e.printStackTrace(); // } Bitmap bitmap = getBitmap(GlobalData.baseUrl + mlist.get(position).getImagePath()); if (bitmap != null) rv.setImageViewBitmap(R.id.imageView1, bitmap); // Return the remote views object. return rv; }
From source file:com.sip.pwc.sipphone.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);//from w w w. jav a 2s . co m nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }
From source file:com.csipsimple.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new NotificationCompat.Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);//from ww w. j a v a2 s.com nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }
From source file:com.sonetel.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new NotificationCompat.Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);//w w w . j ava 2 s .c o m nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.getNotification() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }
From source file:org.dalol.orthodoxmezmurmedia.modules.player.PlayerNotificationDelegate.java
public void showNotification(MezmurPlayerService service, String text) { Intent playerIntent = new Intent(service, MezmursPlayerActivity.class); Intent dashboardIntent = new Intent(service, MezmurDashboardActivity.class); PendingIntent intent = TaskStackBuilder.create(service).addNextIntentWithParentStack(dashboardIntent) .addNextIntent(playerIntent).getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.player_small_notification); views.setOnClickPendingIntent(R.id.player_pause, getPendingAction(service, "pause")); views.setOnClickPendingIntent(R.id.player_previous, getPendingAction(service, "previous")); views.setOnClickPendingIntent(R.id.player_next, getPendingAction(service, "next")); views.setOnClickPendingIntent(R.id.player_close, getPendingAction(service, "stop")); views.setTextViewText(R.id.player_song_name, text); views.setViewVisibility(R.id.player_progress_bar, View.GONE); mNotificationBuilder = new NotificationCompat.Builder(service).setSmallIcon(R.mipmap.ic_launcher) .setPriority(NotificationCompat.PRIORITY_MAX).setWhen(System.currentTimeMillis()) .setContentIntent(intent).setOngoing(true).setContent(views); service.startForeground(NOTIFICATION_ID, mNotificationBuilder.build()); }
From source file:br.com.bioscada.apps.biotracks.widgets.TrackWidgetProvider.java
/** * Updates total time.// w ww.j av a2 s.co m * * @param context the context * @param remoteViews the remote views * @param ids the item's ids * @param tripStatistics the trip statistics */ private static void updateTotalTime(Context context, RemoteViews remoteViews, int[] ids, TripStatistics tripStatistics, boolean isRecording, boolean isPaused) { if (isRecording && !isPaused && tripStatistics != null) { long time = tripStatistics.getTotalTime() + System.currentTimeMillis() - tripStatistics.getStopTime(); remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime() - time, null, true); remoteViews.setViewVisibility(ids[1], View.GONE); remoteViews.setViewVisibility(ids[2], View.GONE); remoteViews.setViewVisibility(ids[3], View.VISIBLE); } else { remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime(), null, false); remoteViews.setViewVisibility(ids[1], View.VISIBLE); remoteViews.setViewVisibility(ids[2], View.GONE); remoteViews.setViewVisibility(ids[3], View.GONE); String totalTime = tripStatistics == null ? context.getString(R.string.value_unknown) : StringUtils.formatElapsedTime(tripStatistics.getTotalTime()); remoteViews.setTextViewText(ids[0], context.getString(R.string.stats_total_time)); remoteViews.setTextViewText(ids[1], totalTime); } }
From source file:eu.power_switch.widget.activity.ConfigureReceiverWidgetActivity.java
private void saveCurrentConfiguration() { try {/* w w w .j a v a2 s. c om*/ // First, get the App Widget ID from the Intent that launched the Activity: Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null && extras.containsKey(AppWidgetManager.EXTRA_APPWIDGET_ID)) { int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); // Perform your App Widget configuration: Apartment selectedApartment = getSelectedApartment(); Room selectedRoom = selectedApartment.getRoom(spinnerRoom.getSelectedItem().toString()); Receiver selectedReceiver = selectedRoom.getReceiver(spinnerReceiver.getSelectedItem().toString()); // save new widget data to database ReceiverWidget receiverWidget = new ReceiverWidget(appWidgetId, selectedRoom.getId(), selectedReceiver.getId()); DatabaseHandler.addReceiverWidget(receiverWidget); // When the configuration is complete, get an instance of // the AppWidgetManager by calling getInstance(Context): AppWidgetManager appWidgetManager = AppWidgetManager .getInstance(ConfigureReceiverWidgetActivity.this); // Update the App Widget with a RemoteViews layout by // calling updateAppWidget(int, RemoteViews): RemoteViews remoteViews = new RemoteViews(getString(eu.power_switch.shared.R.string.PACKAGE_NAME), R.layout.widget_receiver); LinkedList<Button> buttons = selectedReceiver.getButtons(); remoteViews.setTextViewText(R.id.textView_receiver_widget_name, selectedApartment.getName() + ": " + selectedRoom.getName() + ": " + selectedReceiver.getName()); int buttonOffset = 0; for (Button button : buttons) { // set button action RemoteViews buttonView = new RemoteViews( getString(eu.power_switch.shared.R.string.PACKAGE_NAME), R.layout.widget_receiver_button_layout); SpannableString s = new SpannableString(button.getName()); s.setSpan(new StyleSpan(Typeface.BOLD), 0, button.getName().length(), 0); buttonView.setTextViewText(R.id.button_widget_universal, s); if (SmartphonePreferencesHandler.getHighlightLastActivatedButton() && selectedReceiver.getLastActivatedButtonId().equals(button.getId())) { buttonView.setTextColor(R.id.button_widget_universal, ContextCompat.getColor(getApplicationContext(), R.color.color_light_blue_a700)); } PendingIntent pendingIntent = WidgetIntentReceiver.buildReceiverWidgetActionPendingIntent( getApplicationContext(), selectedApartment, selectedRoom, selectedReceiver, button, appWidgetId * 15 + buttonOffset); buttonView.setOnClickPendingIntent(R.id.button_widget_universal, pendingIntent); remoteViews.addView(R.id.linearlayout_receiver_widget, buttonView); buttonOffset++; } appWidgetManager.updateAppWidget(appWidgetId, remoteViews); // Finally, create the return Intent, set it with the // Activity result, and finish the Activity: Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_OK, resultValue); finish(); } } catch (Exception e) { StatusMessageHandler.showErrorMessage(this, e); } }
From source file:com.hang.exoplayer.PlayService.java
public void showNotification() { String title = "XXXXXXXX"; String description = "YYYYYYYYYYYYY"; NotificationCompat.Builder builder = new NotificationCompat.Builder(PlayService.this).setAutoCancel(false) .setOngoing(true);/*from www . ja v a 2s . c om*/ Class<?> targetClass = PlayActivity.class; Intent notificationIntent = new Intent(PlayService.this, targetClass); PendingIntent pendingIntent = PendingIntent.getActivity(PlayService.this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); Intent playPauseIntent = new Intent(ExoApplication.getApplication(), PlayService.class); playPauseIntent.putExtra(ACTION_PLAY_PAUSE, true); Intent previousIntent = new Intent(ExoApplication.getApplication(), PlayService.class); previousIntent.putExtra(ACTION_PREVIOUS, true); Intent nextIntent = new Intent(ExoApplication.getApplication(), PlayService.class); nextIntent.putExtra(ACTION_NEXT, true); Intent dismissIntent = new Intent(ExoApplication.getApplication(), PlayService.class); dismissIntent.putExtra(ACTION_EXIT, true); PendingIntent playPendingIntent = PendingIntent.getService(PlayService.this, 1, playPauseIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent previousPendingIntent = PendingIntent.getService(PlayService.this, 2, previousIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent nextPendingIntent = PendingIntent.getService(PlayService.this, 3, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent dismissPendingIntent = PendingIntent.getService(PlayService.this, 4, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification_high_version_no_live); contentView.setTextViewText(R.id.songName, title); contentView.setTextViewText(R.id.artist, description); boolean isPlaying = SimplePlayer.getInstance().isPlaying(); // Log.d(TAG, "Notification is Playing?" + isPlaying); contentView.setImageViewResource(R.id.play_pause, isPlaying ? R.drawable.ic_noti_play_normal : R.drawable.ic_noti_pause_normal); contentView.setOnClickPendingIntent(R.id.play_pause, playPendingIntent); contentView.setOnClickPendingIntent(R.id.play_pre, previousPendingIntent); contentView.setOnClickPendingIntent(R.id.forward, nextPendingIntent); contentView.setOnClickPendingIntent(R.id.stop, dismissPendingIntent); // builder.setCustomContentView(contentView); builder.setContent(contentView); Notification notification = builder.setSmallIcon(R.mipmap.ic_launcher).build(); startForeground(ID_NOTIFICATION, notification); NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(ID_NOTIFICATION, notification); }