0

Ich habe eine App, die Benachrichtigungen erstellt so oft erstellt. Es wird von einigen hunderttausend Benutzern verwendet. Normalerweise habe ich keine Probleme mit Benachrichtigungen, aber dieser eine Benutzer erhält die Ausnahme, die ich unten hinzugefügt habe. habenandroid.app.RemoteServiceException: Schlechte Benachrichtigung von Paket

Alle Benutzer mit dieser Ausnahme ein TCL-Handy mit Android 4.4.4

jemand eine Idee, was dieses verursachen könnte?

Danke.

Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package mypackage: Couldn't expand RemoteViews for: StatusBarNotification(pkg=mypackage user=UserHandle{0} id=74219 tag=null score=10: Notification(pri=1 contentView=mypackage/0x7f0400a2 vibrate=null sound=null defaults=0x0 flags=0x62 kind=[null])) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:136) 
     at android.app.ActivityThread.main(ActivityThread.java:5095) 
     at java.lang.reflect.Method.invokeNative(Method.java) 
     at java.lang.reflect.Method.invoke(Method.java:515) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
     at dalvik.system.NativeStart.main(NativeStart.java) 

Bearbeiten: Layouts. Ich habe zwei Layouts, eins groß und eins klein.

Klein:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/notification" 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@color/white" 
       android:orientation="horizontal" 
    > 
    <ImageView 
     android:id="@+id/image" 
     android:layout_width="@dimen/notification_image_size_small" 
     android:layout_height="@dimen/notification_image_size_small" 
     android:layout_gravity="center_vertical" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="12dp" 
     android:scaleType="centerCrop" 
     android:src="@drawable/drawable0"/> 
    <TextView 
     android:id="@+id/title" 
     style="@style/title_style" 
     android:text="title"></TextView> 
    <ImageView 
     android:id="@+id/button1" 
     android:layout_width="48dp" 
     android:layout_height="48dp" 
     android:layout_gravity="center" 
     android:background="@drawable/ripple" 
     android:clickable="true" 
     android:scaleType="center" 
     android:src="@drawable/drawable1" 
     android:text="@string/text1" 
     android:contentDescription="@string/test1" 
     /> 
    <ImageView 
     android:id="@+id/button2" 
     android:layout_width="48dp" 
     android:layout_height="48dp" 
     android:layout_gravity="center" 
     android:background="@drawable/ripple" 
     android:clickable="true" 
     android:scaleType="center" 
     android:src="@drawable/drawble2" 
     android:text="@string/text2" 
     android:contentDescription="@string/test2" 
     /> 
    <ImageView 
     android:text="@string/text3" 
     android:contentDescription="@string/text3" 
     android:id="@+id/button3" 
     android:layout_width="32dp" 
     android:layout_height="32dp" 
     android:layout_gravity="center" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:background="@drawable/ripple" 
     android:clickable="true" 
     android:scaleType="center" 
     android:src="@drawable/drawable3"></ImageView> 
</LinearLayout> 

Big:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/notification" 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="110dp" 
       android:background="@color/white" 
       android:clickable="true" 
       android:focusable="true" 
       android:foreground="@drawable/ripple_rect" 
       android:orientation="horizontal"> 
    <ImageView 
     android:id="@+id/image" 
     android:layout_width="@dimen/notification_image_size_big" 
     android:layout_height="match_parent" 
     android:layout_gravity="center" 
     android:scaleType="centerCrop" 
     android:src="@drawable/drawable0_big" 
     /> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:orientation="vertical"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="32dp" 
      android:layout_marginLeft="12dp" 
      android:layout_marginRight="8dp" 
      android:layout_marginTop="8dp" 
      android:orientation="horizontal"> 
      <TextView 
       android:id="@+id/title" 
       android:text="title" 
       style="@style/title_style"></TextView> 
      <ImageView 
       android:id="@+id/button1" 
       android:layout_width="32dp" 
       android:layout_height="32dp" 
       android:layout_gravity="center_vertical" 
       android:background="@drawable/ripple" 
       android:clickable="true" 
       android:scaleType="center" 
       android:src="@drawable/drawable1"/> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/buttons" 
      android:layout_width="match_parent" 
      android:layout_height="48dp" 
      android:layout_marginTop="12dp" 
      android:orientation="horizontal" 
      > 
      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="horizontal"></LinearLayout> 
      <ImageView 
       android:id="@+id/button2" 
       style="@style/buttons_style" 
       android:src="@drawable/drawable2" 
       android:text="@string/text2" 
       android:contentDescription="@string/text2" 
       /> 
      <LinearLayout 
       android:id="@+id/spacer1" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="horizontal"></LinearLayout> 
      <ImageView 
       android:id="@+id/button3" 
       style="@style/buttons_style" 
       android:src="@drawable/drawable3" 
       android:text="@string/text3" 
       android:contentDescription="@string/text3" 
       /> 
      <LinearLayout 
       android:id="@+id/spacer2" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="horizontal"></LinearLayout> 
      <ImageView 
       android:id="@+id/button4" 
       style="@style/buttons_style" 
       android:src="@drawable/drawable4" 
       android:text="@string/text4" 
       android:contentDescription="@string/text4" 
       /> 
      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="horizontal"></LinearLayout> 
      <ImageView 
       android:id="@+id/button5" 
       style="@style/buttons_style" 
       android:scaleX="-1" 
       android:src="@drawable/drawable5" 
       android:text="@string/text5" 
       android:contentDescription="@string/text5" 
       /> 
      <LinearLayout 
       android:id="@+id/spacers3" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="horizontal"></LinearLayout> 
      <ImageView 
       android:id="@+id/button6" 
       style="@style/buttons_style" 
       android:src="@drawable/drawable6" 
       android:text="@string/text6" 
       android:contentDescription="@string/text6" 
       /> 
      <LinearLayout 
       android:id="@+id/spacer4" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="horizontal"></LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

Beim Hinzufügen dieses Layout ich android:scaleX="-1" bemerkt, und ich habe keine Ahnung, warum ich hatte, dass es so dem Benutzer ein, ich werde schicken apk ohne das. Ich habe das da, weil es das gleiche Bild ist, das in die entgegengesetzte Richtung zeigt. Ich werde sehen, ob ich es ersetzen kann, nur für den Fall, dass das Problem ist.

Edit: Sent der Benutzer eine neue Version ohne android:scaleX="-1" und der Absturz immer noch passiert ist.

Bearbeiten: Hinzufügen der Ripple Drawables. Da der Benutzer auf 4.4 ist, würde sie diese hier erhalten:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@color/color_primary_translucent" android:state_focused="true"/> 
    <item android:drawable="@color/color_primary_light_translucent" android:state_pressed="true"/> 
    <item android:drawable="@android:color/transparent"/> 
</selector> 

und

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@color/color_primary_translucent" android:state_focused="true"/> 
    <item android:drawable="@color/color_primary_light_translucent" android:state_pressed="true"/> 
    <item android:drawable="@android:color/transparent"/> 
</selector> 
+1

Können Sie das Layout Ihrer 'RemoteView' veröffentlichen? – azizbekian

+0

Hinzugefügt das Layout, auch während ich hinzufüge, dass ich etwas seltsam bemerkt habe, habe ich 'android: scaleX =" - 1 "' und ich habe keine Ahnung warum. – casolorz

+0

Ich weiß jetzt warum. Weil dieser Knopf derselbe ist wie der andere, aber nur in die andere Richtung zeigt. – casolorz

Antwort

0

würde ich vorschlagen, alle Hintergrund Welligkeit und Vordergrund Wellen aus dem Layout entfernen und die Welligkeit in der Mitteilung zu halten.

In Ihrem Benachrichtigungslayout.

<ImageButton 
      android:id="@+id/notification_base_previous" 
      style="@style/NotificationAction.Previous" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

Jetzt den Stil im Manifest deklarieren.

Dies ist für Ihre individuellen Tasten.

<style name="NotificationAction.Previous" parent="@style/NotificationAction"> 
     <item name="android:src">@drawable/btn_playback_previous_light</item> 
    </style> 

Dies sollte der Elternteil des Stils sein.

<style name="NotificationAction"> 
     <item name="android:layout_width">@dimen/notification_action_width</item> 
     <item name="android:layout_height">@dimen/notification_action_height</item> 
     <item name="android:gravity">center|right</item> 
     <item name="android:scaleType">fitCenter</item> 
     <item name="android:padding">@dimen/notification_action_padding</item> 
     <item name="android:background">?android:selectableItemBackground</item> 
    </style> 

Es funktioniert das alle Geräte, die ich bisher verwendet habe. Bitte guck dir das an.

Verwandte Themen