是否有可能捕獲這些異常?我可以使用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() { ...
是否有可能趕上從我的代碼這個異常?
由於畢加索不是在緩存中加載圖像,所以你不能從代碼中捕捉到異常。如果你在主線程上設置了一個全局的'UncaughtExceptionHandler',那麼你當然可以捕獲所有未經檢查的異常並按照你的意願處理它們。 – corsair992 2015-02-07 15:10:12