Android推送通知:圖標(biāo)未顯示在通知中,而是顯示白色方塊我的應(yīng)用會(huì)生成通知,但我沒(méi)有顯示為該通知設(shè)置的圖標(biāo)。相反,我得到一個(gè)白色方塊。我已經(jīng)嘗試調(diào)整圖標(biāo)的大?。ǔ叽?20x720,66x66,44x44,22x22)。奇怪的是,當(dāng)使用較小尺寸時(shí),白色方塊較小。我已經(jīng)google了這個(gè)問(wèn)題,以及生成通知的正確方法,從我讀過(guò)的代碼應(yīng)該是正確的。可悲的是,事情并不像他們應(yīng)該的那樣。我的手機(jī)是帶有Android 5.1.1的Nexus 5。問(wèn)題還出現(xiàn)在模擬器,帶有Android 5.0.1的三星Galaxy s4和帶有Android 5.0.1的摩托羅拉Moto G上(我借用了這兩款,現(xiàn)在還沒(méi)有)接下來(lái)是通知代碼和兩個(gè)屏幕截圖。如果您需要更多信息,請(qǐng)隨時(shí)提出要求。謝謝你們。@SuppressLint("NewApi") private void sendNotification(String msg, String title, String link, Bundle bundle) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent resultIntent = new Intent(getApplicationContext(), MainActivity.class);
resultIntent.putExtras(bundle);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
resultIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
Notification notification;
Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notificationsound);
notification = new Notification.Builder(this)
.setSmallIcon(R.drawable.lg_logo)
.setContentTitle(title)
.setStyle(new Notification.BigTextStyle().bigText(msg))
.setAutoCancel(true)
.setContentText(msg)
.setContentIntent(contentIntent)
.setSound(sound)
.build();
notificationManager.notify(0, notification);}
添加回答
舉報(bào)
0/150
提交
取消