Android: MediaStyle Уведомление с RemoteInput

В последнее время я работал с уведомлениями, искал действия с Drawables вместо Text и нашел MediaStyle.

Хотя это именно то, что я хотел, у меня также было действие с подключенным к нему RemoteInput, но теперь оно, похоже, исчезло. У меня есть действия MediaStyle так, как я хочу, но когда я щелкаю по нему, входной текст не открывается, а просто открывается действие.

Вот мой код:

public void NotifyRequest (int ID, Context context, Class activity) {
    //Called to enable MediaSession creation
    Looper.prepare();
    intent = new Intent(context, activity);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    //Creating the RemoteInput
    android.support.v4.app.RemoteInput remoteInput = new android.support.v4.app.RemoteInput.Builder(ID + "")
            .setLabel("Enter Text").setAllowFreeFormInput(true).build();
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    MediaSessionCompat mediaSession = new MediaSessionCompat(context, "tag");
    Notification notification =
            new NotificationCompat.Builder(context, "1")
                    .setSmallIcon(R.drawable.ic_launcher_background)
                    //Adding the Action with the RemoteInput
                    .addAction(new NotificationCompat.Action.Builder(R.drawable.ic_launcher_background,"Action", pendingIntent)
                            .addRemoteInput(remoteInput).build())
                    .setContentTitle("TITLE")
                    .setContentText("TEXT")
                    //Setting the style to be MediaStyle and ensuring the action is shown with icon
                    .setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
                            .setShowActionsInCompactView(0)
                            .setMediaSession(mediaSession.getSessionToken()))
                    .build();
    notificationManager.notify(ID, notification);
}

Пожалуйста помоги...

0 ответов

Другие вопросы по тегам