简体   繁体   English

如何自定义推送通知图标?

[英]How to customize push notification icon?

I am using ParsePush to send notifications to my Android users. 我正在使用ParsePush向我的Android用户发送通知。 I want to customize the notification icon that appears in the action bar. 我想自定义出现在操作栏中的通知图标。

Currently the app launcher icon is being displayed. 当前正在显示应用启动器图标。 But I want to change that and use a different icon for notifications. 但是我想更改它,并使用其他图标进行通知。

这是使用重载函数解决的

setDefaultPushCallback(Context context, Class<? extends Activity> cls, int icon)

尝试这个..

NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder( context).setSmallIcon(@android:drawable/btn_star) 
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(notificationTitle)
            .setContentText(notificationMessage)
            .setSmallIcon(R.drawable.YOUR_IMAGE)
            .setContentIntent(resultPendingIntent)
            .setAutoCancel(true)
            .setStyle(bigStyle);

    NotificationManager notificationmanager = (NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
    notificationmanager.notify(nofy_id, builder.build());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM