2011-08-03 16 views
7

cuando tengo que conseguir una cierta imagen o vídeollamada galería de Android tanto para imágenes y video

Me gustó este

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    intent.setType("video/*"); 
    startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD); 

y

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    intent.setType("image/*"); 
    startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD); 

trato de

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    intent.setType("image/* , video/*"); 

pero en el error producido

cómo puedo solucionar este problema ..

gracias a su respuesta

+2

'pero en el error producido' ¿a qué te refieres? Danos detalles del error –

+1

posible duplicado de [Android: deja que el usuario elija la imagen o el video de la galería] (http://stackoverflow.com/questions/4922037/android-let-user-pick-image-or-video- from-gallery) –

Respuesta

0

has necesitado con

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    intent.setType("media/*"); 
    startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD); 
+0

Ocurrió también un error 08-04 16: 15: 52.185: ERROR/AndroidRuntime (12580): android.content.ActivityNotFoundException: No se encontró actividad para manejar el intento {act = android.intent.action.GET_CONTENT typ = media/*} – user876102

0

¡Probar

intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
startActivityForResult(intent, 1); 

Obras de 2.1

+0

esto solo funciona para imágenes, sin incluir videos – Jacky

9

Pruebe esto

final Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT); 
galleryIntent.setType("image/* video/*"); 
startActivityForResult(galleryIntent, REQUEST_CODE); 
+0

Esto no funciona para mí. Estoy demandando a mi Samsung Galaxy S3. Por favor recomiende. –

0

También estaba teniendo el mismo problema y encontré la solución.

Intent pickerIntent = new Intent(Intent.ACTION_GET_CONTENT); 
pickerIntent.setType("image/*, video/*"); 
pickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"}); 
startActivityForResult(pickerIntent, REQUEST_CODE_FOR_MEDIA); 

La clave aquí es pickerIntent.putExtra (Intent.EXTRA_MIME_TYPES, nuevo String [] { "/ * imagen", "video/*"});

Cuestiones relacionadas