I have encountered a strange problem while working with a bitmap, I have an activity where I have a button where onClick() method is set to selectImage(view) and the method definition is as follows
public void selectImage(View v){
Intent imagePickerIntent = new Intent(Intent.ACTION_PICK);
File imageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
Uri data = Uri.parse(imageDir.getPath());
imagePickerIntent.setDataAndType(data, "image/*");
startActivityForResult(imagePickerIntent, 20);
}
and onActivityResult method is as follows:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==20){
if(resultCode==RESULT_OK){
Uri outputFileDir = data.getData();
bitmap = BitmapFactory.decodeFile(outputFileDir.getPath(), options);
String result = getImageNameFromUri(outputFileDir);
selectedImageTV = (TextView)findViewById(R.id.selectedImageTV);
selectedImageTV.setText(result);
image.setImageBitmap(bitmap);
}
else{
return;
}
}
}
but decodeFile() method is returning null in Jio Lyf mobile (low resolution) while it is working fine on Xiaomi devices.
How can I assure that decodeFile() method always return decodedBitmap object on all android devices? Please suggest me ways to tackle such problem.