Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – GCM推送通知图标大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在GCM here的官方文档中,他们提到了如何通过此示例为推送通知添加图标

{
    "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...","notification" : {
      "body" : "great match!","title" : "Portugal vs. Denmark","icon" : "myicon"
    }
  }

我的问题是“myicon”是图标的名称,它存在于何处?
例如:我在Android studio中的项目中有drawable“myicon.png”吗?
或者在哪里?
请有人提前解释和感谢

解决方法

使用您的应用程序图标,如.setsmallIcon(R.drawable.appicon),其中appicon是您的drawable文件夹中的.png文件

或者使用此代码

NotificationCompat.builder notificationBuilder = (NotificationCompat.builder) new NotificationCompat.builder(this)
         .setsmallIcon(R.drawable.icond)
         .setContenttitle("Start Launcher")
         .setContentText(messagE)
         .setAutoCancel(true)
         .setOngoing(true)
         .setWhen(System.currentTimeMillis())
         .setContenTintent(pendingIntent);

   notificationmanager notificationmanager = (notificationmanager) getApplicationContext().getSystemservice(Context.NOTIFICATION_serviCE);

   notificationmanager.notify(ID_NOTIFICATION,notificationBuilder.build());

大佬总结

以上是大佬教程为你收集整理的android – GCM推送通知图标全部内容,希望文章能够帮你解决android – GCM推送通知图标所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。