Android Question Gray icon in Notifications

Hello everyone! I faced such a problem: on some devices and the emulator the notification icon is gray, while on my phone (HONOR 9X) the icon is colored and everything is fine. I also used the class Notification, and now I use NB6. Nothing has changed, can anyone have encountered such a problem?

Best regards
 

TILogistic

Expert
Licensed User
Longtime User
see:
 
Upvote 1
see:
Hello, thanks.

I did everything according to the guide and I get an error when compiling:

res\mipmap-anydpi\ic_launcher.xml: error: <adaptive-icon> elements require a sdk version of at least 26.

I have this string in my manifest:
B4X:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="30"/>
If I change the minimum version to 26, what is the risk?
if i change version i get error: failed linking file resources.

the files are in the root directory, if I put them in the "res" folder, then they are deleted during compilation
 
Last edited:
Upvote 0
Post a screenshot where you mark what you mean?
Hello, Sandman, you're right
1631692585462.png


and if i use img with background

1631692978934.png
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Hello, thanks.

I did everything according to the guide and I get an error when compiling:

res\mipmap-anydpi\ic_launcher.xml: error: <adaptive-icon> elements require a sdk version of at least 26.

I have this string in my manifest:
B4X:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="30"/>
If I change the minimum version to 26, what is the risk?
if i change version i get error: failed linking file resources.

the files are in the root directory, if I put them in the "res" folder, then they are deleted during compilation
You can post your manifest and a screenshot here for your review.
 
Upvote 0
You can post your manifest and a screenshot here for your review.
1 image - if i use img with white background
2- with transparent background


my manifest
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
   
SetApplicationAttribute(android:icon, "@mipmap/ic_launcher")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
CreateResource(mipmap-anydpi, ic_launcher.xml,
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@mipmap/background"/>
    <foreground android:drawable="@mipmap/foreground"/>
</adaptive-icon>
)


SetApplicationAttribute(android:label, "$LABEL$")
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Crashlytics)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
 

Attachments

  • 1631701018294.png
    1631701018294.png
    66.2 KB · Views: 268
  • 1631701035811.png
    1631701035811.png
    60.6 KB · Views: 266
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see:

try this.
AddApplicationText(
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/icon" />

)

SetApplicationAttribute(android:theme, "@style/Custom")
CreateResource(values-v20, theme.xml,
<resources>
<style name="Custom" parent="@android:style/Theme.Material.Light.NoActionBar">
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowLightStatusBar">false</item>

</style>
<color name="icon">#1386FF</color> <--- CUSTOM DEFINED BACKGROUND COLOR
</resources>
)
 
Upvote 0
see:

try this.
Hello
I apologize for the absence. Tried this solution, nothing changed. Notification icon still gray
 
Upvote 0

Sifu

Active Member
Before Android 6 or 7 you could use multi-color notification icon. After that only gray or white on transparent background. PNG 32bit.
The icon can be independent from the normal program colored icon.
But I will follow the link and check if I can do it.
 
Upvote 0

Sifu

Active Member
I followed this post: https://www.b4x.com/android/forum/t...mple-instructions-and-tips.123843/post-788829 #24.
So use that online tool, it creates all needed icons except notification, and do as posted at #24. Also the part you have to copy into the manifest editor.
Then I noticed that in folder \Objects\res\drawable\ , there is where your notification icon.png (32bit 128x128 PNG alpha background, white foreground) has to be stored. If you leave it empty, B4A will copy it's own icon.png to it when build the app.
------------------
Also noticed that if B4A detects an error in manifest, and after you corrected, it still encounters the same error. Restart B4A an build again. Then it works.
I saw this wehn I was tryig to use icons generated by Android Studio, it read xml files and argued about color folder which was not used and not in icon folders at all.
So next I tried the above solution. It works, but no other color than white.
 
Upvote 0
Top