I am picking image from gallery and showing image on ImageView. I am able to do it successfully. My problem is when i try to set an image that are captured from camera(.jpg images) they are not shown in imageview just a blank screen comes up. Even images of type .jpg are successfully showed that are not captured from camera. Can't understand the reason, may be due to larger size. Help please Following is my code:
public class ImagePick extends Activity {
private Bitmap bitmap;
private ImageView imv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_upload);
imv = (ImageView) findViewById(R.id.targetimage);
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, 0);
}
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case 0:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex); // file path of selected image
cursor.close();
// Convert file path into bitmap image using below line.
Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
// put bitmapimage in your imageview
imv.setImageBitmap(yourSelectedImage);
}
}
}
}
Thanks in Advance