2015-02-07 150 views
1

是否有可能捕獲這些異常?我可以使用Thread.UncaughtExceptionHandler嗎?處理(畢加索)拋出的異常

java.lang.IllegalArgumentException: RemoteViews for widget update exceeds maximum bitmap memory usage (used: 1000000, max: 921600) The total memory cannot exceed that required to fill the device's screen once. 
     at android.os.Parcel.readException(Parcel.java:1429) 
     at android.os.Parcel.readException(Parcel.java:1379) 
     at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetIds(IAppWidgetService.java:523) 
     at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:333) 
     at com.squareup.picasso.RemoteViewsAction$AppWidgetAction.update(RemoteViewsAction.java:99) 
     at com.squareup.picasso.RemoteViewsAction.complete(RemoteViewsAction.java:43) 
     at com.squareup.picasso.Picasso.deliverAction(Picasso.java:511) 
     at com.squareup.picasso.Picasso.complete(Picasso.java:470) 
     at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:115) 
     at android.os.Handler.dispatchMessage(Handler.java:99) 
     at android.os.Looper.loop(Looper.java:137) 
     at android.app.ActivityThread.main(ActivityThread.java:4963) 
     at java.lang.reflect.Method.invokeNative(Method.java) 
     at java.lang.reflect.Method.invoke(Method.java:511) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 
     at dalvik.system.NativeStart.main(NativeStart.java) 

我看到畢加索是使用處理器拋出異常:

Picasso.HANDLER.post(new Runnable() { ... 

是否有可能趕上從我的代碼這個異常?

+0

由於畢加索不是在緩存中加載圖像,所以你不能從代碼中捕捉到異常。如果你在主線程上設置了一個全局的'UncaughtExceptionHandler',那麼你當然可以捕獲所有未經檢查的異常並按照你的意願處理它們。 – corsair992 2015-02-07 15:10:12

回答

0

顯影劑站點:

使用的RemoteViews對象不能超過 總位圖存儲器,需要以填充屏幕的1.5倍,即。 (屏幕寬度x屏幕 高度x 4 x 1.5)字節。

在您的特定情況下,當從流加載位圖大於可能時發生錯誤。

您需要在比較正確尺寸後對圖像進行解碼!

or via .resize(imageWidth, imageHight) on Picasso library!

希望得到這個幫助:) ..

+0

我已經做到了(我忘記添加調整大小),但我只是好奇,是否有可能捕捉畢加索引發的主線程異常。我想這個錯誤,並沒有崩潰我的應用程序;-) – radzio 2015-02-07 08:54:05

+1

所以試試{..} catch(Exception e) { e.printStackTrace(); } mmm ??! – 2015-02-07 08:58:29

相關問題