Reputation: 712
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.
Upvotes: 3
Views: 4308
Reputation: 21
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.
Upvotes: 1
Reputation: 712
I figured it out: I needed to set the android:label field in my <application>
node in AndroidManifest.xml.
Upvotes: 0
Reputation: 317352
NotificationCompat.Builder sets a default visibility flag of VISIBILITY_PRIVATE. Instead, explicitly set it to VISIBILITY_PUBLIC with a call to setVisibility().
Upvotes: 5