Reg*_*_AG 11 java notifications android push-notification android-notifications
我使用服务来显示通知.在一些罕见的设备上(每天5万用户中有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)
Run Code Online (Sandbox Code Playgroud)
我的通知是用这样的代码制作的(旧式通知,在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);
Run Code Online (Sandbox Code Playgroud)
有关如何解决这个问题的任何想法?
非常感谢 !!!
| 归档时间: |
|
| 查看次数: |
3526 次 |
| 最近记录: |