我正在使用Cordova,我想在事件的状态栏中设置我的应用程序图标(无法清除)。
在本机android中设置FLAG_ONGOING_EVENT和FLAG_NO_CLEAR标志。我希望这可以实现。 在Cordova有没有可用的插件。
对于Native:我可以通过
实现它public void showIcon(String color){
NotificationManager NM=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder nb= new NotificationCompat.Builder(this);
nb.setContentIntent(PendingIntent.getBroadcast(this, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT));
nb.setContentTitle("Stick");
if(color.equals("green"))
nb.setSmallIcon(R.drawable.green);
else
nb.setSmallIcon(R.drawable.red);
Notification notification = nb.build();
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.defaults |= Notification.DEFAULT_SOUND;
NM.notify(0, notification);
}
请查看以下图片
答案 0 :(得分:0)
你看过这个吗? https://github.com/katzer/cordova-plugin-local-notifications
我不知道它是否可以做粘性/不透明部分。