I have a question, I have read both Make notification disappear after 5 minutes and Clearing notification after a few seconds , but I still don't understand the part where they call removing of the notification. I have a incoming firebase notification coming to my phone and If the user does not click on it,I want the notification removed/disappear automatically after 20 seconds. May I know how to implement it?
P.S I did read on the services as well. I am new to Java language and picking it up as I try a little demo. https://developer.android.com/guide/components/services.html
My codes below are crashing my app everytime i receive a notification. Any help will be appreciated.
Edited: Its fully functional. For anyone's reference
private void removeNotification()
{
long delayInMilliseconds = 20000;
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run()
{
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(0);
timer.cancel();
}
}, delayInMilliseconds, 1000);
}