当应用程序在后台时,GCM SDK将自己处理GCM 3.0中的通知。但我无法设置在应用程序在后台时创建的通知的大图标。
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
}此处发送的myicon将显示为小图标。
当应用程序在后台时,可以设置大图标来通知吗?
发布于 2016-10-22 06:55:04
发布于 2016-11-09 18:09:50
您可以在构建通知时使用setLargeIcon()方法为通知设置大图标。
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
............................
.............................
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setColor(ContextCompat.getColor(this, R.color.colorAccent))
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.icon))
.setContentTitle(title)
.setContentText(body)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setGroupSummary(true)
.setStyle(new NotificationCompat.BigTextStyle().bigText(job_title))
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify((int) System.currentTimeMillis() /* ID of notification */, notificationBuilder.build());https://stackoverflow.com/questions/35430985
复制相似问题