再来一个,还是转型异常
问题代码片段:
$r5 = (cn.com.opda.android.sevenkey.WidgetConfig) $r4,<cn.com.opda.android.sevenkey.SevenKeyWidget: void a(android.content.Context,android.content.Intent)>
问题java代码
private void a(Context arg8, Intent arg9) { int i3; int i = 3; int i1 = 2; int i2 = -1; String string = arg9.getAction(); if(string != null) { if(string.equals("com.dianxinos.optimizer.action.SW_TOGGLE")) { Parcelable parcelable = arg9.getParcelableExtra("widget_config"); i = arg9.getIntExtra("switch_id", i2); Object object = SevenKeyWidget.a.get(i); Rect rect = arg9.getSourceBounds(); if(object == null) { return; } else if(parcelable != null) { SevenKeyWidget.a(arg8, ((kf)object), ((WidgetConfig)parcelable), i, rect);//crash
E/AndroidRuntime( 7358): FATAL EXCEPTION: mainE/AndroidRuntime( 7358): java.lang.RuntimeException: Unable to start receiver cn.com.opda.android.sevenkey.SevenKeyWidget: java.lang.ClassCastException: android.app.ActivityManager$RecentTaskInfo cannot be cast to cn.com.opda.android.sevenkey.WidgetConfigE/AndroidRuntime( 7358): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2591)E/AndroidRuntime( 7358): at android.app.ActivityThread.access$1500(ActivityThread.java:171)E/AndroidRuntime( 7358): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1469)E/AndroidRuntime( 7358): at android.os.Handler.dispatchMessage(Handler.java:107)E/AndroidRuntime( 7358): at android.os.Looper.loop(Looper.java:194)E/AndroidRuntime( 7358): at android.app.ActivityThread.main(ActivityThread.java:5468)E/AndroidRuntime( 7358): at java.lang.reflect.Method.invokeNative(Native Method)E/AndroidRuntime( 7358): at java.lang.reflect.Method.invoke(Method.java:525)E/AndroidRuntime( 7358): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:936)E/AndroidRuntime( 7358): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)E/AndroidRuntime( 7358): at dalvik.system.NativeStart.main(Native Method)E/AndroidRuntime( 7358): Caused by: java.lang.ClassCastException: android.app.ActivityManager$RecentTaskInfo cannot be cast to cn.com.opda.android.sevenkey.WidgetConfigE/AndroidRuntime( 7358): at cn.com.opda.android.sevenkey.SevenKeyWidget.a(SevenKeyWidget.java:233)E/AndroidRuntime( 7358): at cn.com.opda.android.sevenkey.SevenKeyWidget.onReceive(SevenKeyWidget.java:202)E/AndroidRuntime( 7358): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2584)E/AndroidRuntime( 7358): ... 10 more
解决方案:
类型检查~
……