I'm having trouble getting the .setSmallIcon(R.drawable.ic_name) attribute of the notification builder to recognize the material icon that I chose using Image Asset Studio in Android Studio. I can get it to work if I choose one that Android has already publicly declared (e.g. .setSmallIcon(R.drawable.ic_dialog_info).
The full Kotlin statement is (using the ic_dialog_info that is recognized):
val notification: Notification = NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Example service")
.setContentText(input)
.setSmallIcon(R.drawable.ic_dialog_info)
.setContentIntent(pendingIntent)
.build()
I've run Image Asset Studio (following these directions on the developers page) which told me to right click on the res folder and choose New->Image Asset.
Then a popup appears and the developer directions say to:
- In the Icon Type field, select Notification Icons.
- Select an Asset Type, and then specify the asset in the field underneath. (For the Clip Art field, click the button (which is to the right of the words "Clip Art"). Once you click the Clip Art button you can choose from a large selection of icons and then click ok. Then I changed the name field to "ic_text".
Here's what the popup looks like at this point:
After clicking on "Next", I get the following popup with the chance to change the Icon path. Here's what that looks like:
I left the run directory path as is and clicked "Finish."
I get a subdirectory under drawable->ic_text with 5 ic_tet.png files as shown below:
When I type: .setSmallIcon(R.drawable.ic_
the autocomplete doesn't show my icon in the list.
I'm using Android Studio Bumblebee 2021.1.1
I do see the folders in the Project Files view:
Can someone tell me what I've missed? Why doesn't the new icon show up in the autocomplete list and what should I change?