How to create Custom Notification in android

后端 未结 4 1187
庸人自扰
庸人自扰 2021-02-10 04:51

I need to create a custom notification instead of the default notification in android. Current notification have a icon,heading and message like below image

4条回答
  •  北海茫月
    2021-02-10 05:12

    I have create notification usingby following http://developer.android.com/wear/notifications/creating.html

    Add code for create notification.

    // Specify the 'big view' content to display the long
    // event description that may not fit the normal content text.
    BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
    bigStyle.bigText(eventDescription);
    
    NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_event)
            .setLargeIcon(BitmapFractory.decodeResource(
                    getResources(), R.drawable.notif_background))
            .setContentTitle(eventTitle)
            .setContentText(eventLocation)
            .setContentIntent(viewPendingIntent)
            .addAction(R.drawable.ic_map,
                    getString(R.string.map), mapPendingIntent)
            .setStyle(bigStyle);
    

提交回复
热议问题