我不知道如何看logcat,im new。这是我的代码,用于显示MySQLDATABASE的记录。我可以从数据库中获取blob文件,并在文本视图上显示它,该文本确定从数据库中获取数据没有错,问题是在我解码并在ImageView上显示,我的应用程序Crash
private void showUsers(String json){
try {
JSONObject jsonObject = new JSONObject(json);
JSONArray result = jsonObject.getJSONArray(Config.TAG_JSON_ARRAY);
JSONObject c = result.getJSONObject(0);
String username = c.getString(Config.TAG_UNAME);
String password = c.getString(Config.TAG_PWORD);
String firstname = c.getString(Config.TAG_FNAME);
String lastname = c.getString(Config.TAG_LNAME);
String birthday = c.getString(Config.TAG_BDAY);
String gender = c.getString(Config.TAG_GENDER);
String image = c.getString(Config.TAG_IMAGE);
editTextUName.setText(username);
editTextPWord.setText(password);
editTextFName.setText(firstname);
editTextLName.setText(lastname);
tvbirthday.setText(birthday);
if (gender.equals("Male")){
radiomale.setChecked(true);
}
if (gender.equals("Female")){
radiofemale.setChecked(true);
}
// i can set the base64 to text
// tvblob.setText(image);
byte[] kahitano = Base64.decode(image,Base64.DEFAULT);
Bitmap decodeimage = BitmapFactory.decodeByteArray(kahitano,0,kahitano.length);
imageblob.setImageBitmap(decodeimage);
} catch (JSONException e) {
e.printStackTrace();
}
}
您使用我在应用程序decode base64 string bitmap
的方法public static Bitmap decodeBase64ToBitmap(String input) {
byte[] decodedByte = Base64.decode(input, 0);
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}