问:更改 Android Studio 中的通知图标

Eve*_*ver 2 android android-notifications firebase firebase-cloud-messaging

我配置了应用程序图标(图 1),但通知图标(通过 Firebase 发送的通知)显示一个灰色矩形(图 2)。通过 Android Studio 2.3 或脚本更改通知图标图像(图 2)的过程是什么?

显现

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.studioshow.studioshow">
<uses-permission android:name="android.permission.INTERNET" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity android:name=".MainActivity">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />


        </intent-filter>
    </activity>
</application>
Run Code Online (Sandbox Code Playgroud)

图 1 图 2

小智 6

在清单文件中。设置元数据。以下代码是我的情况。

   <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"  >
        <activity
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


        <service
            android:name=".MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_launcher" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/whitechoke" />

    </application>
Run Code Online (Sandbox Code Playgroud)