gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:17:50 26 4
gpt4 key购买 nike

我收到有关 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)

我读到 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);

更新:
我发现当我尝试更新以 startForeground() 开始的通知时出现问题,我运行的代码是:

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

但它在 ICS 和 JB 上工作正常,那么为什么它在 Ginger 上会出现问题?

最佳答案

不要直接引用通知,因为您正在使用 NotificationBuilder 创建通知对象。

删除:

 notification.contentView.setProgressBar(android.R.id.progress, 100, (int) download.getProgress(), false);

添加:

 builder.setProgress(int max, int progress, boolean indeterminate)

此外,看起来您正在使用自定义通知布局,请参阅文档如何与构建器一起使用 http://developer.android.com/guide/topics/ui/notifiers/notifications.html

关于Android - 仅在 Android 2.3 上发布的错误通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12843119/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com