I am starting to collect the image from the gallery, but the target always returns using resultcode RESULT_CANCELED. I tried a lot of different codes, but nothing helps me think, maybe something is missing for me, for example, something interfered with the Android manifest?
My code is:
// The Intent Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 0); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK){ Uri targetUri = data.getData(); Bitmap bitmap; try { bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(targetUri)); profileImage.setImageBitmap(bitmap); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
Thank you for your help;)
android android-intent gallery
Decodegnome
source share