Trying to create android notifications with a custom body provided by an XML file. When I try to set the title of these notifications, it does not appear.
Oddly, the subtext continues to show just fine.
Showing a standard notification (no CustomContentView
), and
builder.setContentTitle("foo");
builder.setSubText("bar");
// builder.setCustomContentView(customNotificationView);
Both the title and subtext show.
If I set it to use a custom view, the title disappears. (and instead shows app name)
builder.setContentTitle("foo");
builder.setSubText("bar");
builder.setCustomContentView(customNotificationView);
Am I missing something? Does Android just not use ContentTitle
when you have any kind of CustomView?
I assume what's happening is that the 'content' title is getting removed because we're replacing the 'content' with a new view.
Is there any way to give a notification with custom content a "native" title? (instead of adding text inside the RemoteView that we treat as the title).
misc notes
- using AndroidX versions (
import androidx.core.app.NotificationCompat;
) - The title is removed whether or not I add a decorated style (
.setStyle(new NotificationCompat.DecoratedCustomViewStyle());
-
- The title is removed whether or not I set the custom view via
.setContent
or.setCustomContentView
- The title is removed whether or not I set the custom view via
from Are .setContentTitle and .setCustomContentView mutually exclusive?
No comments:
Post a Comment