当应用已关闭或最小化时,Android中的白色通知

问题描述:

我刚刚在我的Android应用中实施了FCM推送通知,我收到一个奇怪的行为,因为它似乎只在应用打开时加载剪影图标,但当它关闭时或最小化我得到一个白色的圆圈。我认为它向我展示了ic_launcher图标,而不是我的ic_stat_white图标。我在photoshop中创建了我的基本图标,并使用Android Asset Studio获取所有尺寸(https://romannurik.github.io/AndroidAssetStudio/icons-notification.html),并尝试了所有我能找到或想到的解决方案,并在推送通知消息中添加了额外的值(“icon”:“ic_stat_white “),使缓存无效,以及我在Stack Overflow中可以找到的所有内容,但没有任何结果。当应用已关闭或最小化时,Android中的白色通知

在我火力地堡信息服务类,我有以下代码来创建通知:

NotificationCompat.Builder mBuilder = 
       (NotificationCompat.Builder) new NotificationCompat.Builder(this) 
         .setSmallIcon(getNotificationIcon()) 
         .setContentTitle("App name") 
         .setAutoCancel(true) 
         .setContentText(message); 

mBuilder.setContentIntent(resultPendingIntent); 
// Sets an ID for the notification 
int mNotificationId = 001; 
// Gets an instance of the NotificationManager service 
NotificationManager mNotifyMgr = 
       (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
// Builds the notification and issues it. 
mNotifyMgr.notify(mNotificationId, mBuilder.build()); 

和getNotificationIcon方法:

private int getNotificationIcon() { 
    boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.LOLLIPOP);   
    return useWhiteIcon ? R.drawable.ic_stat_white : R.mipmap.ic_launcher; 
} 

我觉得应用程序无法获得访问从应用程序之外的图标或类似的东西,虽然我已经添加

import com.appname.R; 

它似乎并没有被使用。

任何人都知道问题可能在这里?

干杯!

+0

请参阅我的回答同样的问题在这里: https://stackoverflow.com/questions/37616065/android-notification-icon-issue/44879510#44879510 –

即使我从FCM管理面板设置图标,但在PHP中创建我自己的后端控制器后,问题仍然发生,似乎我没有在应用程序中获得此行为,但如果我不调用推送通知用我自己的系统,我仍然得到一个空白的图标(???)。

​​

干杯!

+0

见我的回答同样的问题在这里: HTTPS: //stackoverflow.com/questions/37616065/android-notification-icon-issue/44879510#44879510 –