This is the code that gives notification on start of service
NotificationCompat.Builder mbuild = new NotificationCompat.Builder(getApplicationContext());
Intent in = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent resultIN = PendingIntent.getActivity(getApplicationContext(),code,in,NOTIFICATION_COUNT); mbuild.setSmallIcon(R.drawable.images1);
mbuild.setContentText(NOTIFICATION_COUNT +" New Message");
mbuild.setContentIntent(resultIN); //mbuild.addAction(R.drawable.notifications,NOTIFICATION_COUNT +"New Messages",resultIN);
NotificationManager nmagr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nmagr.notify(1, mbuild.build());
everyting is working correct ..the code opens the target activity but the notification still stays there in the notification bar. i have tried useing mbuil.setautocancel(true); but its doing nothing
Open your phone's Settings app. Notifications. Under "Lock screen," tap Notifications on lock screen or On lock screen. Choose Don't show notifications.
If you're running Android on a Samsung Galaxy smartphone, open the Settings app, scroll down, and tap on Lock screen. Next, tap on Notifications and not the switch next to it. To hide the message content in the Notification bar, make sure the Hide content switch is turned on.
try this
NotificationManager nmagr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification=mbuild.build();
notification.flags = Notification.FLAG_AUTO_CANCEL;
nmagr.notify(1,notification);
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