почему уведомления сворачиваются в kitkat - PullRequest
0 голосов
/ 26 марта 2020

Я создавал пользовательское уведомление с помощью предоставителя уведомлений android и пытаюсь использовать пользовательское уведомление. Ниже приведен код, используемый:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        RemoteViews remoteViews = new RemoteViews(getPackageName(),R.layout.resource_file);
        createNotificationChannel();
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
        builder.setSmallIcon(R.drawable.ic_launcher_background)
                .setContentTitle("mTitle")
                .setContentText("Some text that I have written for larger con" +
                        " I have written for larger content")
                .setCustomBigContentView(remoteViews)
                .setPriority(NotificationCompat.PRIORITY_DEFAULT);
        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(notificationID, builder.build());
    }


    private void createNotificationChannel() {
        // Create the NotificationChannel, but only on API 26+ because
        // the NotificationChannel class is new and not in the support library
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            CharSequence name = getString(R.string.channel_name);
            String description = getString(R.string.channel_description);
            int importance = NotificationManager.IMPORTANCE_DEFAULT;
            NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
            channel.setDescription(description);
            // Register the channel with the system; you can't change the importance
            // or other notification behaviors after this
            NotificationManager notificationManager = getSystemService(NotificationManager.class);
            notificationManager.createNotificationChannel(channel);
        }
    }  

Макет, используемый для remoteViews, выглядит следующим образом:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:orientation="vertical"
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="I have some text that I want to display"
        android:padding="5dp"
        />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="25dp"
        android:src="@drawable/ic_launcher_background"
        android:scaleType="fitXY"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="I have some text that I want to display"
        android:padding="5dp"
        />



</LinearLayout>   

При Kitkat 4.4.2 в моем эмуляторе уведомление отображается так, как ожидалось:
enter image description here

но на Kitkat 4.4.4 уведомление не распространяется за пределы этого небольшого раздела, независимо от того, насколько я установил размер родительского элемента remoteViews LinearLayout:
enter image description here
Есть ли способ форсировать расширение или это ошибка в этой версии Kitkat? (Устройство является основным ядром samsung galaxy)

...