从包com.packagename发布的错误通知:无法展开RemoteViews:StatusBarNotification

时间:2015-09-20 13:37:00

标签: android notifications

我在错误报告中看到多次出现以下异常:

android.app.RemoteServiceException: Bad notification posted from package com.packagename: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.packagename user=UserHandle{0} id=0 tag=null score=0 key=0|com.packagename|0|null|10324: Notification(pri=0 contentView=com.packagename/0x109009d vibrate=null sound=content://settings/system/notification_sound defaults=0x0 flags=0x18 color=0x00000000 originalPackageName=N originalUserId=0 vis=PRIVATE))
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1894)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:145)
   at android.app.ActivityThread.main(ActivityThread.java:6872)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

该应用目前作为测试版发布,因此拥有少量(约500名)用户。 (它似乎主要影响Galaxy Note 4用户)。

我假设(可能不正确)由于我的应用程序定期生成通知而抛出此内容。

通知生成如下:

NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.setBigContentTitle("Title");
    inboxStyle.setSummaryText("Summary");

    Spannable sAuthor = new SpannableString(author);
    sAuthor.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, author.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    inboxStyle.addLine(sAuthor);
    inboxStyle.addLine(message);

    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(mContext)
                    .setSmallIcon(R.drawable.ic_notification_mail)
                    .setContentTitle("Title")
                    .setTicker("Ticker")
                    .setContentText("Content Text")
                    .setAutoCancel(true)
                    .setOnlyAlertOnce(true)
                    .setStyle(inboxStyle)
                    .setNumber(messages.size());

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    builder.setSound(alarmSound);


    Intent notifyIntent = new Intent(mContext, MyActivity.class);
    notifyIntent.putExtra(MyActivity.ARG_ITEM_ID, myObj);

    // Sets the Activity to start in a new, empty task
    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    // Creates the PendingIntent
    PendingIntent notifyPendingIntent =
            PendingIntent.getActivity(
                    mContext,
                    0,
                    notifyIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT
            );
    builder.setContentIntent(notifyPendingIntent);

    NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    // mId allows you to update the notification later on.
    mNotificationManager.notify(0, builder.build());

如果有人知道这是异常的原因,或者可能知道其他原因,我会非常感激听到这些。

由于

0 个答案:

没有答案