天天看點

android notification自動消失,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的新手.