Я хочу отобразить кнопки действий в панели уведомлений. Уведомление работает, но я не вижу ни одной кнопки. Я прочитал документ разработчика Android и различные примеры в Интернете, но я не мог найти никакой большой разницы с моим кодом. Я сделал, как следующее:Кнопки действий не отображаются в уведомлении
public void showNotification(Context context) {
NotificationManager mNotifyMgr = (NotificationManager);
context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder = new NotificationCompat.Builder(context);
Intent prevIntent = new Intent(mContext, PlayAudioService.class);
prevIntent.setAction(ACTION_PREV);
PendingIntent piPrev = PendingIntent.getService(mContext, 0, prevIntent, 0);
Intent playIntent = new Intent(mContext, PlayAudioService.class);
playIntent.setAction(ACTION_PLAY);
PendingIntent piPlay = PendingIntent.getService(mContext, 0, playIntent, 0);
Intent nextIntet = new Intent(mContext, PlayAudioService.class);
nextIntet.setAction(ACTION_NEXT);
PendingIntent piNext = PendingIntent.getService(mContext, 0, nextIntet, 0);
mBuilder.setSmallIcon(smallIcon)
.setContentTitle("Title")
.setContentText("Text")
.setTicker("Ticker")
.setWhen(0)
//.setStyle(new NotificationCompat.BigTextStyle().bigText(title))
.addAction (R.drawable.ic_previous, "Prev", piPrev)
.addAction (R.drawable.ic_play, "Play", piPlay)
.addAction (R.drawable.ic_next, "Next", piNext);
Intent notifyIntent = new Intent(context, MainActivity.class);
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent piNotify =
PendingIntent.getActivity(
mContext,
0,
notifyIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(piNotify);
mNotifyMgr.notify(mNotificationId, mBuilder.build());
}
В деятельности:
showNotification(this);
Мой Android целевой SDK версии 15 и я использую последнюю версию библиотеки поддержки v4. Что мне не хватает и не понял правильно?
Ваш ответ будет оценен.
Спасибо за ваш ответ, очень полезно. Я не видел, что API был введен из API 16. – sunghun