Почему bigText не возвращает тип стиля

Почему метод bigText() не возвращает тип стиля внутри setStyle Или почему setStyle требует Style Type?

увидеть изображение

https://drive.google.com/open?id=1BRYjh4OQp83-VcFmcRjXQpU798asu-16

пытаюсь сделать уведомление

    NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "kdfjds", NotificationManager.IMPORTANCE_DEFAULT);
        notificationManager.createNotificationChannel(notificationChannel);
    }

    Notification.Builder notification = new Notification.Builder(this);

    notification.setSmallIcon(R.drawable.ic_launcher_foreground);

    Bitmap largeIcon = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher_background);

    notification.setLargeIcon(largeIcon);
    notification.setContentTitle("order");
    notification.setContentText("You have new order");

    Intent goToOrder = new Intent(this,MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this,97,goToOrder,0);
    notification.setContentIntent(pendingIntent);
    notification.setStyle(new NotificationCompat.BigTextStyle().bigText(this.getString(R.string.charging_reminder_notification_title)));
    notification.setAutoCancel(true);


    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            notification.setPriority(Notification.PRIORITY_HIGH);
        }
    }



    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationManager.notify(NOTIFICATION_ID,notification.build());
    }
0
0
33
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Попробуйте использовать Notification.BigTextStyle() вместо NotificationCompat.BigTextStyle().

P.S. Проблема здесь в том, что вы пытаетесь перепутать пакеты, вы, по сути, пытаетесь использовать android.support.v4.app.NotificationCompat.BigTextStyle, когда ожидается android.app.Notification.Style.

Но я изменил импорт android.support.v4.app.NotificationCompat.BigTextStyle на импорт android.app.Notification.Style, и я использовал NotificationCompat, но проблема с NotificationCompat все еще существует.

Musaed Alosaimi 20.07.2019 18:00
NotificationCompat — это класс, содержащийся в пакете android.support.v4.app. Вы можете использовать NotificationCompat.BigTextStyle, если вы используете NotificationCompat везде.
Chrisvin Jem 20.07.2019 18:01

Библиотеки поддержки предназначены для обратной совместимости с более ранними версиями Android.

Chrisvin Jem 20.07.2019 18:04

Я понял, что уведомление Notification.Builder = новое уведомление.Builder (это); должно быть уведомление Notification.Builder = новый NotificationCompat.Builder (это); для использования NotificationCompat.BigTextStyle Я также решил проблему, изменив построитель с Notification на NotificationCompat, чтобы можно было использовать NotificationCompat.BigTextStyle

Musaed Alosaimi 21.07.2019 01:26

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