7
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, 0, 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, 0, new Intent(), 0));
Notification noti = mBuilder.build();
mNotificationManager.notify(notificationid++, noti);
このコードは機能し、ワープされた広告テキストを表示します。ただし、後続の通知が発生すると、前の通知でテキストが失われます。誰でもこの問題の解決に役立つことができますか?それは私が間違って設定しているものかもしれない、私はアンドロイドのapiに新しいです。NotificationCompat.BigTextStyleの内容は新しい通知で消えます
この動作を抑制し、常に拡張コンテンツを表示する方法はありますか? – Watson
いいえ、私はそうは思わない – Floern