Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid 4.0 custom notification like google music
    primarykey
    data
    text
    <p>I want to create a custom notification with a progress bar and a delete button.</p> <p>Screenshot:</p> <p><img src="https://i.stack.imgur.com/OMKC7.png" alt="enter image description here"></p> <p>I succeed to create a custom notification with a progress bar, but I did not manage to create the delete event. I want to cancel the notification and stop the upload once the user click on the "x" (as in google music, so i don't want to start an activity to clear the notification).</p> <p>Here is my working code : </p> <pre><code> notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); int icon = R.drawable.ic_launcher; CharSequence tickerText = "Hello"; long when = System.currentTimeMillis(); notification = new Notification(icon, tickerText, when); CharSequence contentTitle = "My notification"; CharSequence contentText = "Hello World!"; Intent notificationIntent = new Intent(context, UploadEventsReceiver.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); notification.contentView = new RemoteViews(context.getPackageName(), R.layout.upload_progress); notification.contentView.setOnClickPendingIntent(R.id.text, contentIntent); notificationManager.notify(this.notificationId, notification); </code></pre> <p>At the line </p> <pre><code>Intent notificationIntent = new Intent(context, UploadEventsReceiver.class); </code></pre> <p>I tried with a BroadCast receiver without "broadcasting" but I don't know if it's the right way to do it and I didn't succeed to make it work. What should I use and how to use it ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload