Android - 仅在Android 2.3上发布错误通知

dma*_*ato 6 notifications android android-notifications android-2.3-gingerbread

我在显示通知时收到有关Android 2.3崩溃的报告.我的堆栈跟踪是:

android.app.RemoteServiceException: Bad notification posted from package com.megadevs.hubi: Couldn't expand RemoteViews for: StatusBarNotification(package=com.megadevs.hubi id=1 tag=null notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x62))
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1048)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3687)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
    at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

我已经读过Android 2.3与AnimatedImageView存在一些问题,但我认为我没有使用它......我运行的用于显示通知的代码是:

NotificationCompat2.Builder builder = new NotificationCompat2.Builder(getApplicationContext());
notification = builder.setOngoing(true)
    .setAutoCancel(false)
    .setPriority(NotificationCompat2.PRIORITY_DEFAULT)
    .setSmallIcon(notificationSmallIcon)
    .setWhen(System.currentTimeMillis())
    .setContentIntent(notificationIntent)
    .setContentTitle(downloads.elements().nextElement().getFileName())
    .setProgress(100, (int) downloadable.getDownload().getProgress(), false)
    .build();
startForeground(DL_NOTIFICATION, notification);
Run Code Online (Sandbox Code Playgroud)

更新:
我发现当我尝试更新使用startForeground()启动的通知时出现问题,我运行的代码是:

notification.contentView.setProgressBar(android.R.id.progress, 100, (int) download.getProgress(), false);
mNotificationManager.notify(DL_NOTIFICATION, notification);
Run Code Online (Sandbox Code Playgroud)

但是它在ICS和JB上运行正常,那为什么它会给Ginger带来问题呢?

Dur*_*amy 0

您是否看到类似 android.view.InflateException 的内容?另请检查您将 notificationSmallIcon 保存在哪里?你能确保png文件存在于drawable文件夹中吗?不只是在drawable-mdpi等中?

您可以在运行应用程序时发布完整的日志吗?