-4

My question is about if there is any way to create a timer and make the android app send a notification when the timer reaches a certain time on android studio.

  • Possible duplicate of [How to set a timer in android](https://stackoverflow.com/questions/1877417/how-to-set-a-timer-in-android) – Mihai Chelaru Apr 23 '18 at 00:26
  • 1
    Welcome to StackOverFlow! When asking a question, we expect that you have tried to solve your problem first. Then, if you cannot find a solution, post the piece of code that isnt working and the problem. This rule is made to avoid spam. – CodingM Apr 23 '18 at 00:34

1 Answers1

0

Try this one

final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
    @Override
    public void run() {
        Notification noti = new Notification.Builder(mContext)
            .setContentTitle("New mail from " + sender.toString())
            .setContentText(subject)
            .setSmallIcon(R.drawable.new_mail)
            .setLargeIcon(aBitmap)
            .build();
    }
}, 5000); //run after 5secs
Android_K.Doe
  • 753
  • 1
  • 4
  • 11