When you are in the Runnable
, this
became the Runnable
and not the context
of your Activity
. Since you must pass a context
as parameter, it triggers an error. To get the correct context
, you can use the same way as the one you used for the Toast
:
Notification notification = new Notification.Builder(getApplicationContext());
In this case, you will effectively pass your Activity
context
and not your Runnable
.