android Drawable转换成Bitmap失败

错误代码:
08-0706:42:30.48228497-28497/app.tianxiayouE/AndroidRuntime﹕FATALEXCEPTION:main
Process:app.tianxiayou,PID:28497
java.lang.RuntimeException:UnabletostartactivityComponentInfo{app.tianxiayou/app.tianxiayou.AppInfoActivity}:java.lang.ClassCastException:android.graphics.drawable.VectorDrawablecannotbecasttoandroid.graphics.drawable.BitmapDrawable
atandroid.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
atandroid.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
atandroid.app.ActivityThread.access$800(ActivityThread.java:151)
atandroid.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
atandroid.os.Handler.dispatchMessage(Handler.java:102)
atandroid.os.Looper.loop(Looper.java:135)
atandroid.app.ActivityThread.main(ActivityThread.java:5257)
atjava.lang.reflect.Method.invoke(NativeMethod)
atjava.lang.reflect.Method.invoke(Method.java:372)
atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
atcom.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Causedby:java.lang.ClassCastException:android.graphics.drawable.VectorDrawablecannotbecasttoandroid.graphics.drawable.BitmapDrawable
atapp.tianxiayou.AppInfoActivity.initAppInfo(AppInfoActivity.java:70)
atapp.tianxiayou.AppInfoActivity.onCreate(AppInfoActivity.java:52)
atandroid.app.Activity.performCreate(Activity.java:5990)
atandroid.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
atandroid.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            atandroid.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            atandroid.app.ActivityThread.access$800(ActivityThread.java:151)
            atandroid.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            atandroid.os.Handler.dispatchMessage(Handler.java:102)
            atandroid.os.Looper.loop(Looper.java:135)
            atandroid.app.ActivityThread.main(ActivityThread.java:5257)
            atjava.lang.reflect.Method.invoke(NativeMethod)
            atjava.lang.reflect.Method.invoke(Method.java:372)
            atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            atcom.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
方法中的代码
AppInfotempInfo=newAppInfo();
//获取应用名字
tempInfo.setAppName(packageInfo.applicationInfo.loadLabel(getPackageManager()).toString());
//ICON
icondrawable=packageInfo.applicationInfo.loadIcon(getPackageManager());
bitmapDrawable=(BitmapDrawable)icondrawable;
tempInfo.setAppIcon(bitmapDrawable.getBitmap());
求大神指导
慕侠2389804
浏览 342回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript