Jeo*_*rge 2 notifications android android-notifications android-studio
我正在尝试使用 .setContentText() 中的换行符发出通知,但这不起作用。
我的通知的生成器
builder.setContentTitle("Notification")
.setSmallIcon(R.drawable.notif)
.setContentText("Example1 "+"\n"+" Example2")
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setContentIntent(contentIntent)
.setTicker("testing it")
.setVibrate(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400})
.setPriority(Notification.PRIORITY_HIGH);
Run Code Online (Sandbox Code Playgroud)
在通知中: Example1 Example2
但是我需要
Example1
Example2
Run Code Online (Sandbox Code Playgroud)
据我所知,换行符在 中被忽略setContentText(),因为它是浓缩的。你可以试试BigTextStyle,例如:
builder.setContentTitle("Notification")
.setSmallIcon(R.drawable.notif)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText("Example1\nExample2")
)
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setContentIntent(contentIntent)
.setTicker("testing it")
.setVibrate(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400})
.setPriority(Notification.PRIORITY_HIGH);
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅:https : //developer.android.com/reference/android/app/Notification.BigTextStyle。
| 归档时间: |
|
| 查看次数: |
1764 次 |
| 最近记录: |