我配置了应用程序图标(图像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>
答案 0 :(得分:2)
在清单文件中。设置元数据。 以下代码是我的理由。
<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>
答案 1 :(得分:0)
编辑:我的回答无关紧要:我没有读到Firebase
消息传递部分。
只需使用由setSmallIcon(int)及其Compat
对应方提供的NotificationBuilder。
您可以通过传递resource
文件夹来检索图标。
R.drawable.my_icon
作为参数。