本文介绍了android怎么样创建永不关闭的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用NotificationCompat.builder创建的通知。但我不能设置通过它的标志,使uncancelable。
任何人都可以请帮我解决我的问题,我会感激你的。 :)
感谢您:)
noti_intent =新意图(这一点,Main.class);
noti_pend = PendingIntent.getActivity(在此,noti_id,noti_intent,0);
noti_manager =(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
NotI位=新NotificationCompat.Builder(本)
.setSmallIcon(R.drawable.status_ico)
.setContentTitle(下一步警报设置为铃声的)
.setTicker(报警设置为戒)
.setContentText(next_date.getText()++ next_time.getText())
.setWhen(System.currentTimeMillis的())
.setContentIntent(noti_pend)
.setAutoCancel(假);
解决方案
替换 setAutoCancel(真)
与 setOngoing(真)
。
I have created notification using NotificationCompat.builder. But i cant set flags through it to make uncancelable.
Can anyone please help me to solve my problem, i would be grateful to you. :)
Thank you :)
noti_intent = new Intent(this, Main.class);
noti_pend = PendingIntent.getActivity(this, noti_id, noti_intent, 0);
noti_manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
noti = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.status_ico)
.setContentTitle("Next alarm is set to ring on")
.setTicker("Alarm is set to ring")
.setContentText(next_date.getText()+" "+next_time.getText())
.setWhen(System.currentTimeMillis())
.setContentIntent(noti_pend)
.setAutoCancel(false);
解决方案
Replace setAutoCancel(true)
with setOngoing(true)
.
这篇关于android怎么样创建永不关闭的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!