I want to select an image from gallery and place that selected image in the ImageView
. I have also an Intent
that will take picture through camera and place it in ImageView
and it is working well. But, gallery Intent
is only opening the chooser and then select the image, but it is not getting placed in the ImageView
In Log this error is coming up
E/OpenGLRenderer: SFEffectCache:clear(), mSize = 0
Open Gallery Method
private void openGallery() {
tvGallery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "Opening Gallery, Please wait..", Toast.LENGTH_SHORT).show();
private int PICK_IMAGE_REQUEST = 1;
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
galleryIntent.setType("image/*");
startActivityForResult(galleryIntent,PICK_IMAGE_REQUEST);
Log.e("Status:", "Photopicker canceled");
}
});
}
onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
/*camera preview*/
if (resultCode == RESULT_OK) {
Bitmap bp = (Bitmap) data.getExtras().get("data");
previewView.setImageBitmap(bp);
}
/*gallery preview*/
else if (requestCode == PICK_IMAGE_REQUEST) {
if (resultCode == RESULT_OK) {
Uri selectedImage = data.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 picturePath = cursor.getString(columnIndex);
cursor.close();
previewView = (ImageView) findViewById(R.id.imgPostIssue);
previewView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
}
}
}
LOG ERROR
09-08 15:40:02.355 30860-30860/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:03.836 30860-30860/bluecoppertech.com.taskmeld E/Status:: Photopicker canceled
09-08 15:40:07.460 30860-30860/bluecoppertech.com.taskmeld E/OpenGLRenderer: SFEffectCache:clear(), mSize = 0
09-08 15:40:21.754 30860-30860/bluecoppertech.com.taskmeld E/OpenGLRenderer: SFEffectCache:clear(), mSize = 0
09-08 15:40:32.885 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.885 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.885 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.895 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.905 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.915 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.915 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.945 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.965 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.975 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:32.995 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method bluecoppertech.com.taskmeld.Activity.activity.utils.PostNewIssue.access$super
09-08 15:40:33.225 32246-32246/bluecoppertech.com.taskmeld E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
See Question&Answers more detail:
os