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)
.
Try including the .setOngoing(true)
in your code:
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)
.setOngoing(true)
.setAutoCancel(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With