I am using Netcore Smartech Android SDK version 2.2.19. I have added the meta-data tag for the notification icon as per their documentation but I am not able to see the icon. Gray square comes in the place of the notification icon.
<meta-data
android:name="SMT_SMALL_NOTIFICATION_ICON"
android:value="#drawable/ic_notif"/>
<!-- I also tried below syntax. -->
<meta-data
android:name="SMT_SMALL_NOTIFICATION_ICON"
android:value="ic_notif.png"/>
Try passing only the icon name as they specified <small_notification_icon_name>. Your code should look like this.
<meta-data
android:name="SMT_SMALL_NOTIFICATION_ICON"
android:value="ic_notif"/>
Also, make sure your icon sizes match with the valid sizes for the notification icon. You can refer to this document.
Related
I'm using flutter_launcher_icons package to generate launcher icons for the apps. Everything works as expected, the launchers are generated and set for Android and iOS. However, on Android push notifications, the launcher is displayed as a white square, even though the icon is black.
I tried to add the icon as meta-data on the manifest file as well as with the Notification builder as a small icon, the result is the same.
Here's the output from my pubspec.yaml file
flutter_icons:
android: true
ios: true
image_path_android: "assets/icon/ic_logo_new.png"
image_path_ios: "assets/icon/ic_logo_new.png"
remove_alpha_ios: true
adaptive_icon_background: "assets/icon/ic_launcher_background.png"
adaptive_icon_foreground: "assets/icon/ic_logo_new.png"
Is there anyone who faced this issue? Any help is appreciated.
just add custom icon to incoming notification.
Just add a meta-data inside tag in your manifest file.
Reference
<application
android:name="io.flutter.app.FlutterApplication"
android:label="When Coin"
android:icon="#mipmap/ic_launcher">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#mipmap/ic_stat_ic_notification" />
How can I show same icon while app is on background or foreground? Below I have attached my screenshot
I have used this app icon for my notification
Thanks in advance!
Yes. This does happen. It can be fixed by setting color to the icon ,when the notification is generated from inside the app.
NotificationCompat.Builder(
this,
CHANNEL_ID
)
.setSmallIcon(//your vector)
.setColor(ContextCompat.getColor(this, //color of the icon(mostly this may be
the primary/secondary color that has been set ,according to the theme, in this
case some hex of red)))
To keep it consistent, even for the notification generated in the background, a line can be written in the manifest:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/(your vector)” />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/(color of the icon)” />
I cannot update the icon on the homescreen. It is the green robot default android icon. How can I change this to the icon?
I have added icons in the app > src > res folder for different resolutions.
I am uploaing my app using the play console. Any ideas?
My manifest states:
android:icon="#mipmap/ic_launcher"
The name matches the image in the assets folders.
Here is a link to my repo:
https://bitbucket.org/matthisco/ejected-calendar/src/master/android/app/src/main/
Change project to android
than go to res>mipmap>paste your icon there (iconName.png)
replace
android:icon="#mipmap/ic_launcher" in manifest
to
android:icon="#mipmap/iconName"
You can update the homescreen icon as follows:
In AndroidManifest.xml under application tag
<application
android:icon="#mipmap/yourdesiredIcon"/> // replace ic_launcher to desired icon
Goto app > src > main > res
rename your icon to ic_launcher.png and paste it to all mipmap folders
The correct folder where the Android icon must be placed is res->mipmap-xxxx where xxxx signals the screen resolution.
Also check that your manifiest is using it. Open the manifest and in the application tag you should have something like this:
android:icon="#mipmap/ic_launcher"
Also verify you icon is named ic_launcher.
As you can see that entry in the manifest says "go look for the icon in the mipmap folder, use the one named ic_launcher"
I faced the same issue, but I realized that in the Android Manifest
android:roundIcon="#mipmap/ic_launcher"
android:icon="#mipmap/ic_launcher"
were pointing to the same images, which were square. The phone I was testing on had a round icon, and so the default android image was displaying, I presume because the format was incorrect.
When I then tested on a phone with a square image, the images were displaying correctly.
When the notif is displayed, the icon is showed. But when I expand the notification menu, it's a grey icon.
My manifest :
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#android:color/transparent" />
For exemple, here in this screenshot, the icon is displayed (the green one) :
But then :
For the android above lollipop OS devices, the notification Icon background color should be grey and should follow the notification icon guidelines provided by android.
If you run the same application in the KitKat the existing works fine.
Anyhow there is a solution,
Notification bar icon turns white in Android 5 Lollipop
But it will not work when your app is in closed state.
Check with the below link for icon design guidelines.
Reference web address. Click here for more Info
NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext(), notificationId+"")
.setContentTitle(getContext().getString(R.string.app_name))
.setContentText(message.getAlert())
.setAutoCancel(true);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setSmallIcon(R.drawable.notification_icon_transparent);
} else {
builder.setSmallIcon(R.drawable.notification_icon_color);
}
used two notification icon
1) Transparent background. Example icon : https://i.stack.imgur.com/XlEzp.png
2) Color (generally use 'ic_launcher_icon')
I have downloaded a Android Navigation drawer sample project and trying to use that. At the initial state, i don't know how to change the navigation drawer title icon to different icon image. where exactly is this image located specifically? Is it under any specific Res->drawable folder? Please find the screenshot, where I rounded the navigation title icon image, which I want to change now.
You can change it in your AndroidManifest.xml, put your icon in your res/drawable folder and set the "logo" param to your icon like this:
<manifest>
...
<application
...
android:logo="#drawable/your_image_file_name">
</application>
...
</manifest>
You can find it being set in your manifest. It automatically accesses #drawable/ic_launcher as your app icon
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Byustudiestab" >
You should change your app icon in AndroidManifest.xml
android:icon="#drawable/ic_launcher"
where exactly is this image located specifically? Is it under any specific Res->drawable folder?
To find where the image is located in eclipse, do the following: res -> drawable
Also the image might be locate in either drawable-hdpi, drawable-ldpi, drawable-xhdpi, drawable-xxhdpi
Once you find the image location, replace the image with an image of your choice. Either give the image a new name or keep it the same name as the old image. If you decide to give the image a new name you will have to head on over to the AndroidManifest.xml and replace the old name given to the old image with the new name that you gave the new image.
android:logo="#drawable/your_image_file_name"
Another option:
getSupportActionBar().setLogo(R.drawable.yourImage);
or
getActionBar().setLogo(R.drawable.yourImage);
Note: Attribute "logo" is only used in API level 11 and higher android:logo requires api (if you don't use getSupportActionBar)