最初のティッカー テキストを表示せずに進行中の通知を表示しようとしています。コンストラクターでティッカー テキストを null に設定することで、古いスタイルの Notification でこれを機能させることができました。
mNotification = new Notification(R.drawable.ic_stat_playing, null, System.currentTimeMillis());
ただし、この方法で Notification をインスタンス化することは推奨されなくなり、代わりに Notification.Builder の使用が推奨されることに気付きました。ただし、ティッカー テキストを null に設定しても、ティッカー テキストなしで通知を表示することはできません。
Notification.Builder builder = new Notification.Builder(this);
CharSequence contentText = "contentText here";
Intent launchIntent = new Intent(this, MainActivity.class);
// The PendingIntent to launch our activity if the user selects this
// notification
PendingIntent contentIntent = PendingIntent.getActivity(this, -1,
launchIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ic_stat_playing)
.setLargeIcon(null)
.setTicker(null)
.setOnlyAlertOnce(true)
.setWhen(System.currentTimeMillis())
.setContentTitle(contentTitle)
.setOngoing(true)
.setContentText(contentText);
mNotification = builder.getNotification();
startForeground(NOTIFICATION_ID, mNotification);
新しい Notification.Builder でティッカー表示をオフにすることはできませんか? そうですか、非推奨のコードから更新できなくなるので残念です。
編集 - 最終的に機能したコード:
mNotification = builder.getNotification();
mNotification.tickerView = null;
startForeground(NOTIFICATION_ID, mNotification);