Escoger una imagen de la galería en el estudio androide?

Alguien puede decirme cuál es el problema, no está funcionando, así que por favor ayude rápido realmente necesito:

imagePick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Contact Image"),1); } }); public void onActivityResult(int reqCode, int resCode, Intent data) { if(resCode==RESULT_OK) { if(reqCode==1) { imageURI=data.getData(); iv.setImageURI(data.getData()); } } } 

Esto está funcionando para mí.

 private final static int SELECT_PHOTO = 12345; imagePick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, SELECT_PHOTO); } }); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Here we need to check if the activity that was triggers was the Image Gallery. // If it is the requestCode will match the LOAD_IMAGE_RESULTS value. // If the resultCode is RESULT_OK and there is some data we know that an image was picked. if (requestCode == SELECT_PHOTO && resultCode == RESULT_OK && data != null) { // Let's read picked image data - its URI Uri pickedImage = data.getData(); // Let's read picked image path using content resolver String[] filePath = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(pickedImage, filePath, null, null, null); cursor.moveToFirst(); String imagePath = cursor.getString(cursor.getColumnIndex(filePath[0])); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(imagePath, options); imageView.setImageBitmap(bitmap); // Do something with the bitmap // At the end remember to close the cursor or you will end with the RuntimeException! cursor.close(); } } 
  • ¿Cómo usar el estilo de notificación predeterminado?
  • Cómo cambiar el color de fondo del menú de ActionBar (android 4 y 5)
  • ¿Es posible agregar una propiedad personalizada a un estilo en un recurso android?
  • Atributos de estilo de estilo personalizado AlertDialog
  • ¿Cómo heredar el atributo de estilo de Android?
  • Creación de TimePickerDialog con estilo personalizado en Android
  • Anulación de los atributos de estilo referenciados
  • Cómo diseñar un SearchView en la barra de acciones de Android
  • Cómo establecer un atributo de estilo mediante programación en una vista
  • Cómo cambiar el estilo de un ImageButton de forma programática
  • Cómo establecer el estilo ListView en el recurso?
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.