Java AdaptiveCondrawable无法强制转换为android.graphics.drawable.BitmapDrawable
在OnePlus设备中获取android Oreo中的此错误Java AdaptiveCondrawable无法强制转换为android.graphics.drawable.BitmapDrawable,java,android,Java,Android,在OnePlus设备中获取android Oreo中的此错误 FileOutputStream out = new FileOutputStream(mIconFile); BitmapDrawable bitmapDrawable = (BitmapDrawable) mAppIcon; Bitmap bitmap = bitmapDrawable.getBitmap(); bitmap.compress(Bitmap.CompressF
FileOutputStream out = new FileOutputStream(mIconFile);
BitmapDrawable bitmapDrawable = (BitmapDrawable) mAppIcon;
Bitmap bitmap = bitmapDrawable.getBitmap();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
java.lang.ClassCastException:android.graphics.drawable.AdaptiveCondrawable无法强制转换为android.graphics.drawable.BitmapDrawable您的JSON不正确,对于JSON解析,您可以使用GSON解析器。
教程在下面一行中将color对象看作另一个JSON,即内部JSON。你的json字符串包含一些错误。json应该是这样的:[{“id”:“1”,“厚度”:“102mm”,“描述”:“JKDSHFJKDSHJKKKKKJ”,“保证”:“1年”,“颜色”:“[{“QMW3WBeV\”:“白色\”,“SWW23sdf\”:“5\”,{“QMW3WBeV\”:“奶油\,”SWW23sdf\”:“0\”,{“QMW3WBeV\”:“栗色\”,“SWW23sdf\”:“6\”,{“QMW3WBeV\”:“灰色\”,“SWW23sdf\”:“4\”)}我完成了字符串color=jsonObject1.getString(“color”);颜色=颜色。替换(“\”,“”);JSONArray jsonArraycolr=新JSONArray(颜色);对于(int j=0;j