Har*_*dar 11 notifications android whatsapp
我想创建通知,如WhatsApp应用程序中用于Android设备的弹出通知.
我该怎么做?由于我是新用户,我无法上传屏幕截图
请参考此链接:http://cdn6.staztic.com/cdn/screenshot/appsdroidnotifythemeicecreamsandwich-1-1.jpg
对于屏幕截图和帮助我:)
他们被称为'单挑'通知.这个页面有一个很好的解释.
总而言之,将优先级设置为高(或最大).
这是我的代码中的一个例子:
public static void notify(Context context, int id, int titleResId,
int textResId, PendingIntent intent) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
String title = context.getString(titleResId);
String text = context.getString(textResId);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.notification)
.setContentTitle(title)
.setContentText(text)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true)
.setWhen(System.currentTimeMillis())
.setTicker(title)
.setContentIntent(intent);
notificationManager.notify(id, builder.build());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20407 次 |
| 最近记录: |