getActiveNotifications()使内存不足

时间:2017-10-09 14:48:35

标签: android out-of-memory

我遇到了致命的问题。我需要通过电话收到通知。那条线就是这样:

 StatusBarNotification[] notificationsArray = getActiveNotifications();

但它有时会在某些设备上出错:

Fatal Exception: java.lang.OutOfMemoryError
   at android.graphics.Bitmap.nativeCreateFromParcel(Bitmap.java)
   at android.graphics.Bitmap.access$000(Bitmap.java:34)
   at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:1565)
   at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:1557)
   at android.widget.RemoteViews$BitmapCache.(RemoteViews.java)
   at android.widget.RemoteViews.(RemoteViews.java)
   at android.widget.RemoteViews.(RemoteViews.java)
   at android.widget.RemoteViews$2.createFromParcel(RemoteViews.java:3049)
   at android.widget.RemoteViews$2.createFromParcel(RemoteViews.java:3047)
   at android.app.Notification.(Notification.java)
   at android.service.notification.StatusBarNotification.(StatusBarNotification.java)
   at android.service.notification.StatusBarNotification$1.createFromParcel(StatusBarNotification.java:121)
   at android.service.notification.StatusBarNotification$1.createFromParcel(StatusBarNotification.java:118)
   at android.os.Parcel.createTypedArray(Parcel.java:1935)
   at android.app.INotificationManager$Stub$Proxy.getActiveNotificationsFromListener(INotificationManager.java:528)
   at android.service.notification.NotificationListenerService.getActiveNotifications(NotificationListenerService.java:149)
   at com.hexati.lockscreentemplate.service.NotificationService.sendAll(NotificationService.java:380)
   at com.hexati.lockscreentemplate.service.NotificationService.access$200(NotificationService.java:60)
   at com.hexati.lockscreentemplate.service.NotificationService$NotificationsReceiver.onReceive(NotificationService.java:419)
   at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:772)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:146)
   at android.app.ActivityThread.main(ActivityThread.java:5487)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
   at dalvik.system.NativeStart.main(NativeStart.java)

我如何解决这个问题?

0 个答案:

没有答案