I am trying to transfer byte[] to another intent and turn it into Bitmap,However its crash my app without errors in logcat,the logcat just restart. Some of the photos are working fine and some of them just crash the activity.
If I don't get the image value,only the other data,its working great,but when I try to get the image too, its restart.
First I am getting the image byte[] from parse and I transfer it through intent to another activity and convert it to bitmap.
Getting data from parse:
ParseQuery<ParseObject> query = ParseQuery.getQuery("Feed");
query.orderByDescending("createdAt");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
if (e == null){
for (ParseObject allData : objects) {
image = (ParseFile) allData.get("Pictures");
if (image == null){
Log.e("Image", "NULL");
}else{
image.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
if (e == null){
date = allData.getCreatedAt();
DateFormat df = new SimpleDateFormat("HH:mm:ss\nyyyy-MM-dd");
reportDate = df.format(date);
arrayList.add(new MyData(reportDate,allData.getString("UserName"),allData.getString("BussinessName"),data));
}
adapter = new MyAdapter(FeedActivity.this, arrayList);
feedListView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
});
}
}
}
}
});
Sending the byte[] to another activity:
feedListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
// TODO Auto-generated method stub
Intent intent = new Intent(FeedActivity.this, BusinessDetails.class);
MyData data = (MyData) adapter.getItem(position);
String BusinessNamePage = data.getBusinessName();
String DatePage = data.getDate();
String UserNamePage = data.getUserName();
byte[] PicturePage = data.getPicture();
intent.putExtra("image",PicturePage);
intent.putExtra("BussinessName", BusinessNamePage);
intent.putExtra("Date", DatePage);
intent.putExtra("username", UserNamePage);
startActivity(intent);
}
});
Getting the byte[] in another activity and convert it to bitmap:
public class BusinessDetails extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_business_details);
ImageView imageView = findViewById(R.id.imageViewTitle);
TextView businessName = findViewById(R.id.businessNameDetailTitle);
TextView userName = findViewById(R.id.userNameValue);
TextView date = findViewById(R.id.dateValue);
Intent intent = getIntent();
byte[] image = intent.getByteArrayExtra("image");
Bitmap bmp = BitmapFactory.decodeByteArray(image, 0, image.length);
imageView.setImageBitmap(bmp));
businessName.setText(intent.getStringExtra("BussinessName"));
date.setText(intent.getStringExtra("Date"));
userName.setText(intent.getStringExtra("username"));
}
}
Thank you !
EDIT: The error - https://ibb.co/ngJGWBJ