Android TransactionTooLargeException与NotificationManager

时间:2019-06-16 14:05:58

标签: android notifications android-glide android-bitmap

发送自定义布局的通知时,我遇到class MeasurementSerializer(MeasurementSerializer): sensor = SensorDetailSerializer(many=False, read_only=True) sensorpositions = SensorpositionSerializer(many=True, read_only=True) experiment = ExperimentDetailForMeasurementSerializer(many=False, read_only=True) filetype = FiletypeSerializer(many=False, read_only=True) class ExperimentDetailForMeasurementSerializer(ExperimentSerializer): persons = PersonSerializer(many=True, read_only=True) conditions = ConditionSerializer(many=True, read_only=True) location = LocationSerializer(many=False, read_only=True) layout = LayoutSerializer(many=False, read_only=True) 异常。

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> ,我正在使用Glide进行加载,并且提供了固定尺寸的64x64 DP转换为设备像素。

0 个答案:

没有答案