Android TransactionTooLargeException с NotificationManager - PullRequest
0 голосов
/ 16 июня 2019

Я получаю исключение TransactionTooLargeException при отправке уведомления с пользовательским макетом.

java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 588636 bytes
       at android.app.NotificationManager.notifyAsUser(NotificationManager.java:380)
       at android.app.NotificationManager.notify(NotificationManager.java:286)
       at android.app.NotificationManager.notify(NotificationManager.java:270)

Вероятно, это связано с растровыми изображениями в макете, но это происходит не на всех устройствах, поэтому я не хочу уменьшать или удалять эти растровые изображения, могу ли я что-то еще сделать?

Это мой макет

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:background="@color/colorPrimary"
    android:orientation="horizontal">


    <ImageView
        android:layout_margin="0dp"
        android:id="@+id/userImage"
        android:layout_width="64dp"
        android:layout_height="64dp"
        tools:src="@tools:sample/avatars" />

    <LinearLayout
        android:layout_marginStart="5dp"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:maxLines="1"
            android:id="@+id/userName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/yellow"
            android:textSize="20sp"
            android:textStyle="bold"
            tools:text="@tools:sample/full_names" />

        <TextView
            android:id="@+id/time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:textColor="@color/yellow"
            android:textStyle="bold"
            tools:text="0:25" />

    </LinearLayout>


    <ImageView
        android:id="@+id/muteButton"
        android:padding="1dp"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_gravity="center"
        android:layout_marginStart="8dp"
        android:background="@drawable/circle2"
        android:src="@drawable/mute_icon"
        android:tint="@color/black" />

    <ImageView
        android:id="@+id/micButton"
        android:padding="1dp"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_gravity="center"
        android:layout_marginStart="8dp"
        android:background="@drawable/circle2"
        android:src="@drawable/speaker"
        android:tint="@color/black" />

    <ImageView
        android:id="@+id/endCallButton"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:layout_marginStart="8dp"
        android:background="@drawable/circle2"
        android:src="@mipmap/call_end_icon" />

    <ImageView
        android:visibility="gone"
        android:id="@+id/answerButton"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:layout_marginStart="8dp"
        android:background="@drawable/circle2"
        android:src="@mipmap/call_icon" />

    <FrameLayout
        android:layout_width="8dp"
        android:layout_height="0dp"/>

</LinearLayout>

Единственное растровое изображение, которое я загружаю динамически, это userImage, я использую Glide для его загрузки и предоставляю фиксированный размер 64x64 DP, преобразованный в пиксели устройства.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...