Asked  10 Months ago    Answers:  5   Viewed   13 times

Does anyone know if there is a way to group a notification in the status bar but not in the list of notifications?

I want to show only one icon in the status bar but when the user drags down the "notifications list" it should be several notifications with different intents.

As I understood there is only possible to either group both notifications on both places or to create several notifications which will cause several notifications in the status bar. Is this the case?

 Answers

5

As I undestood there is only possible to either group both notifications on both places or to create several notifications which will cause several notifications in the status bar. Is this the case?

Yes, but you can create as complex of a custom Notification view as you want, via the contentView field on Notification. This is a RemoteViews, better known as the what you use for rendering a home screen app widget. So, while there can only be one entry in the notification drawer for you, you can have it have several buttons each firing a separate PendingIntent.

Friday, August 13, 2021
 
c0m4
 
3
  • A1: To remove the status bar icon, use this trick:

    builder.setSmallIcon(android.R.color.transparent); //Tested and worked in API 14
    
  • A2: To make persistant Notification, add this line:

    builder.setOngoing(true)
    
Sunday, August 1, 2021
 
Jeremy
 
1

You can't inflate just any view in a RemoteView. Change your View to an empty TextView or ImageView.

A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:

FrameLayout
LinearLayout
RelativeLayout

And the following widget classes:

AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
ViewFlipper
ListView
GridView
StackView
AdapterViewFlipper

Descendants of these classes are not supported.

Reference: http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout

Thursday, August 19, 2021
 
Aidan D
 
3

Okay so with this new information I would try something like this:

SpannableString bigText = (SpannableString) mExtras.get(Notification.EXTRA_TEXT);
if(bigText != null){
    body = bigText.toString();
}

Edit: After reviewing the source I would try this:

CharSequence bigText = (CharSequence) mExtras.getCharSequence(Notification.EXTRA_TEXT);
if(bigText != null){
    body = bigText.toString();
}
Tuesday, October 19, 2021
 
kwichz
 
1

Have you tried using http://developer.android.com/reference/android/widget/RemoteViews.html ?

Monday, November 8, 2021
 
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :