Created
November 28, 2014 10:33
-
-
Save jgilfelt/8105b5ca07776a4359c2 to your computer and use it in GitHub Desktop.
Notification whose content is partially redacted on API 21 secure lockscreens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Notification buildNotification() { | |
NotificationCompat.Builder builder = new NotificationCompat.Builder(context) | |
.setCategory(NotificationCompat.CATEGORY_EVENT) | |
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) // default | |
.setContentTitle(title) | |
.setContentText(shortText) | |
.setStyle(new NotificationCompat.BigTextStyle().bigText(fullText)) | |
.setSmallIcon(R.drawable.ic_stat_notification) | |
.setColor(context.getResources().getColor(R.color.my_color)) | |
.setContentIntent(intent); | |
// show all the above in public contexts | |
builder.setPublicVersion(builder.build()); | |
// only show actions when unlocked | |
builder.addAction(R.drawable.ic_action, context.getString(R.string.action), actionIntent); | |
return builder.build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment