gpt4 book ai didi

java - android.app.RemoteServiceException : at android. app.ActivityThread$H.handleMessage 发送通知时

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:42:59 31 4
gpt4 key购买 nike

我使用服务来显示通知。在一些罕见的设备上(每天 50 000 名中的 3 名用户),我遇到以下崩溃(可以在 Google Play 开发者控制台中看到;仅在 Android 4.x 设备上):

android.app.RemoteServiceException: 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5327)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method:0)

我的通知是用这样的代码发出的(旧式通知,在 Android 6+ 中已弃用,但仍然有效;错误出现在 Android 4.x 上,代码未弃用):

Notification notification = new Notification(icon, "Custom Notification", when);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setImageViewResource(R.id.notifWeatherImageView, WeatherRowTools.getImageForWeatherCode(weatherCodeString));

....some stuff here...

notification.contentView = contentView;
notification.contentIntent = contentIntent;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults = 0;
mNotificationManager.notify(1, notification);

关于如何解决这个问题有什么想法吗?

非常感谢!!!

最佳答案

我在我的构建中看到了类似的问题 - 只有 Kitkat 设备大量抛出这些问题 - Android 操作系统版本:4.4.4、4.4.2、4.2.2、4.0.4

我们通过更改 Notification 使用的 drawable 解决了类似的问题。

.addAction(R.drawable.ic_forward_black_24dp, VIEW_ACTION, pendingIntentView);

我们停止使用 vector 资源并开始使用图像资源。

R.drawable.ic_forward_black_24dp 不再使用 xml 文件( vector 资源),我们现在使用 png 文件(图像资源)。

关于java - android.app.RemoteServiceException : at android. app.ActivityThread$H.handleMessage 发送通知时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44266510/

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