我正在使用FCM生成通知。它在许多其他设备上运行良好,但在MI A1上缺少通知图标。
这是我的代码
dependencies {
compile 'com.google.dagger:dagger:2.x'
annotationProcessor 'com.google.dagger:dagger-compiler:2.x'
}
答案 0 :(得分:0)
在manifest.xml中添加下一个
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_launcher" />
.
.
.
</application>
答案 1 :(得分:0)
试试这个
NotificationCompat.Builder notificationBuilder = new
NotificationCompat.Builder(this)
.setSmallIcon(getNotificationIcon())
.setContentTitle(titleDisplay)
.setContentText(contentDisplay)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setColor(whiteIcon ? getResources().getColor(R.color.colorPrimary) : getResources().getColor(android.R.color.transparent));
private int getNotificationIcon() {
boolean whiteIcon = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
return whiteIcon ? R.drawable.icon: R.mipmap.ic_launcher;
}