微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android 图标被选中而不是通知图标

如何解决Android 图标被选中而不是通知图标

我正在使用 FCM 通知,并且在我的 AndroidManifest.xml 中设置了以下内容

<Meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/splash" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message.  -->
<Meta-data
    android:name="com.google.firebase.messaging.default_notification_color"
    android:resource="@color/splash_color" />

其中 splash 是透明的 png 图像。

我也在同一个清单文件中设置了 android 应用程序图标:

 <application
        android:name="io.Flutter.app.FlutterApplication"
        android:label="myapp"
        android:icon="@drawable/ic_launcher"> 

发生的情况是,当弹出通知时,它会选择 ic_launcher 而不是飞溅。如果我替换 ic_launcher 并将飞溅作为我的 android 图标,那么我会看到通知图标。

但是,如果我这样做,那么我的应用程序图标(现在是透明图像)会变成黑色作为我不想要的背景。我希望 ic_launcher 成为我的背景颜色。我不明白为什么在 android:icon 中定义的图像被接收通知

解决方法

对于遇到此问题的任何人,请将元标记放在应用程序标记之后。不要将它们放在活动标签下。所以是这样的:

<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_notification" />
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?