I am using NotificationCompat.Builder to create a notification:
Intent activityIntent = new Intent( this,
MyActivity.class );
PendingIntent resultingActivityPendingIntent = getPendingIntent( activityIntent );
// create notification for foreground service
m_notificationBuilder = new NotificationCompat.Builder( this );
m_notificationBuilder.setSmallIcon( R.mipmap.ic_launcher );
m_notificationBuilder.setTicker( "some text" );
m_notificationBuilder.setContentTitle( "some text" ) );
m_notificationBuilder.setContentIntent( resultingActivityPendingIntent );
startForeground( ONGOING_NOTIFICATION_ID,
m_notificationBuilder.build() );
The notification functions as expected in the status bar and notification dropdown, but for the lockscreen, it shows this:
com.myname.mypackage
Contents hidden
How do I change the line where my package name is?
I have tried setting content text and content info in the notification builder, but it doesn't change anything.
There must be something obvious I'm missing because other apps, even if their content is hidden, will have that line say something relevant, like:
USB connectivity
Contents hidden
I am using SDK 19, build tools 19, targeting 19, min SDK 11.
NotificationCompat.Builder sets a default visibility flag of VISIBILITY_PRIVATE. Instead, explicitly set it to VISIBILITY_PUBLIC with a call to setVisibility().
Well you can do it another way also.
You can call the setVisibility() method of the notificationCompat.Builder where you can set a VISIBILITY_PUBLIC flag, that will mirror whatever your title and contentText is when the screen is unlocked.
Changing the label field will also change the name of your application in the app drawer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With