'android, in what case the os will create action button in the notification
In the doc it says:
In Android 10 (API level 29) and higher, the platform automatically generates notification action buttons if an app does not provide its own.
so is it that if there is no action button added to the notification, the os will add it?
Intent intent = new Intent(this, MyActivity.class);
intent.setAction(ACTION_VIEW);
intent.setData(Uri.parse("https://www.text.com"));
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent)
//.addAction(R.drawable.ic_action, "action", pendingIntent);
but if comment out .addAction(R.drawable.ic_action, "action", pendingIntent)
, it does not show any action
button.
How to see a os platform automatically created action button
?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|