android – NotificationCompat.BigTextStyle内容在新通知上消失

String ns = Context.NOTIFICATION_SERVICE;
        notificationmanager mnotificationmanager = (notificationmanager) this.getSystemService(ns);
        int icon = R.drawable.ic_launcher;
        CharSequence tickerText = title;
        long when = System.currentTimeMillis();             


        Uri alarmSound = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
        if(alarmSound == null){
              alarmSound = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_ringtone);
            if(alarmSound == null){
                alarmSound = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
            }
        }           

        Intent intent = new Intent();
        PendingIntent pendingIntent 
        = PendingIntent.getActivity(this,intent,0);    

        NotificationCompat.BigTextStyle bigxtstyle =
        new NotificationCompat.BigTextStyle();          
        bigxtstyle.bigText(text);               
        bigxtstyle.setBigContentTitle(title);


        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setStyle(bigxtstyle)
            .setSmallIcon(icon)
            .setAutoCancel(true)

            .setSound(alarmSound)
            .setDeleteIntent(pendingIntent)                     
            .setContentIntent(PendingIntent.getActivity(this,new Intent(),0));     


        Notification noti = mBuilder.build();


        mnotificationmanager.notify(notificationid++,noti);

代码有效,并显示通过自动换行宣传的文本.但是,当后续通知发生时,先前的通知会丢失其文本.有人可以帮忙解决这个问题吗?这可能是我设置错误的东西,我是android apis的新手.

解决方法

Android认情况下仅显示一个展开的通知.您的通知不会丢失内容,只会被压缩并仅显示正常的单行内容.但似乎您没有指定此内容,因此压缩通知为空.

您可以使用setContentTitle()setContentText()设置单行文本.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...