tap for more information or stop the app
On Android 10, you MUST call setSmallIcon on your notification, otherwise the notification will be ignored. (The same is not true on Android 11, where it works regardless of whether you set the small icon.) If you fail to set the small icon, instead of your notification you will see a canned Android notification instead of your own:
This code with setSmallIcon
works:
new Notification.Builder(getApplicationContext(), channelId) .setSmallIcon(Icon.createWithResource(this, R.drawable.myicon)) .setLargeIcon(Icon.createWithResource(this, R.drawable.myicon)) .setContentTitle(title) .setContentText(text) .setCategory(Notification.CATEGORY_CALL) .setExtras(extras) .setAutoCancel(true) .addAction(android.R.drawable.ic_menu_call, "Accept", piAcceptIntent) .setFullScreenIntent(pendingIntent, true);
This code without setSmallIcon
causes the problem:
new Notification.Builder(getApplicationContext(), channelId) .setLargeIcon(Icon.createWithResource(this, R.drawable.myicon)) .setContentTitle(title) .setContentText(text) .setCategory(Notification.CATEGORY_CALL) .setExtras(extras) .setAutoCancel(true) .addAction(android.R.drawable.ic_menu_call, "Accept", piAcceptIntent) .setFullScreenIntent(pendingIntent, true);
In the comments above, @royas and @Flamychandayo found this solution. I am adding this as an answer to help make the solution more clear to those who come across this question.