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" />
Related
I have a simple android app which I would like implement dynamic color from material 3. I use Google guideline (https://codelabs.developers.google.com/codelabs/apply-dynamic-color#0) (I override onCreate() in Application class and I add this class in android manifest), and dynamic color is working on emulator (sdk 31/32/33), however on physical device is not work (sdk 32). And if I to add colors-v31 in project and override color, it's work on phone. What could be the problem? Do I understand correctly that it is not necessary to override color resources for dynamic colors?
Application.kt
class Application: Application() {
override fun onCreate() {
super.onCreate()
DynamicColors.applyToActivitiesIfAvailable(this)
}
}
AndroidManifest.xml
<application
android:name=".Application"
<activity>
android:exported="true"
</activity>
<!-- others xmls tags -->
</appication>
In themes.xml I use parent Theme.Material3.DayNight.NoActionBar and colors from material theme builder
Screenshots of how it's now and how it should be: color is pink, but application is green (default color for this app)
green app
and how app should be: if color system is orange
and app is orange
if i override colors in v-31 it work. but i was read android devs codelabs and i think it is not necessary to override colors
These palettes are specific to Android 12 (API 31) so you will need to place relevant files in folders with a -v31 suffix unless your app has a minimum SDK set to 31 or higher.
Also in your AndroidManifest.xml file specify an explicit value for android:exported for the activity.
<application>
<activity android:name=".MainActivity"
android:exported="true">
<!-- others xmls tags -->
</application>
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.
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 just published my app on play store and I notice that some Samsung device does not display the icon of my app. They assert the default icon of android studio. Have you an idea what can cause that? i'm confused
<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:theme="#style/AppTheme">
....
</application>
Try This;
File -> New -> Image Asset -> Launcher Icons (Adaptive and Legacy)
For more information;
https://proandroiddev.com/android-adaptive-icons-are-easier-than-you-think-3c66be2dd4dd
https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive
Remove this line..
android:roundIcon="#mipmap/ic_launcher_round"
My issue was solved by restarting the phone.
I thing some device had oreo and pie OS that why device does not show the correct app icon.Now you can delete ic_launcher_round and ic_launcher from mipmap-anydpi-v26
please check this link Launcher Icon is not Shown in Oreo 8.0/8.1
This happened to me when I noticed my mipmap folder is missing but if I search the icons in the project they are there. So I created a mipmap folder manually New > Android resource directory > Mipmap. Then I generated the image asset for the icons again.
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.