Notification multiline

后端 未结 5 812
时光取名叫无心
时光取名叫无心 2020-12-28 12:53

How to make a long notification multiline. I am using the below code snippet but its not working:

NotificationCompat.Builder mBuilder = new NotificationCompa         


        
5条回答
  •  别那么骄傲
    2020-12-28 13:40

    Bitmap icon1 = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);  
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setSmallIcon(getNotificationIcon()).setLargeIcon(icon1)
                .setTicker(title)
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setTicker(message)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(title))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
                .setPriority(Notification.PRIORITY_MAX)
                .setContentIntent(pIntent)
                .setContent(remoteViews)
                 .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                .setVibrate(new long[] {1, 1, 1})
                 .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher))
                .setDefaults(Notification.DEFAULT_SOUND)
                .setDefaults(Notification.DEFAULT_ALL);
        NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        Notification notify = new Notification();
        notify.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONLY_ALERT_ONCE;
        Random random = new Random();
        notificationmanager.notify(random.nextInt(), builder.build());
    

提交回复
热议问题