Android推送通知:圖標未顯示在通知中,而是顯示白色方塊我的應用會生成通知,但我沒有顯示為該通知設置的圖標。相反,我得到一個白色方塊。我已經嘗試調整圖標的大?。ǔ叽?20x720,66x66,44x44,22x22)。奇怪的是,當使用較小尺寸時,白色方塊較小。我已經google了這個問題,以及生成通知的正確方法,從我讀過的代碼應該是正確的。可悲的是,事情并不像他們應該的那樣。我的手機是帶有Android 5.1.1的Nexus 5。問題還出現在模擬器,帶有Android 5.0.1的三星Galaxy s4和帶有Android 5.0.1的摩托羅拉Moto G上(我借用了這兩款,現在還沒有)接下來是通知代碼和兩個屏幕截圖。如果您需要更多信息,請隨時提出要求。謝謝你們。@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);}
- 3 回答
- 0 關注
- 3422 瀏覽
添加回答
舉報
0/150
提交
取消