2012-07-06 25 views
5

Estoy tratando de escoger un archivo con cualquiera de estos 3 tipos MIME, y no parece funcionarAndroid recoger la intención

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

Puede alguien sugerir cómo puedo hacerlo?

+0

Ha intentado 'photoPickerIntent.setType ("*/*")'; – user370305

+0

Sí, pero no quiero que las aplicaciones que manejan otros archivos, como editores de texto y otras, solo las que pueden manejar medios –

+0

¿Desea elegir el archivo del almacenamiento externo? – AkashG

Respuesta

1

Escriba a continuación el código en lugar de su código, puede ayudarlo.

private static final int PICTURE = 0; 
private static final int VIDEO = 1; 
private static final int AUDIO = 2; 


Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); 
String title = GET_PICTURE; 

if (this.mediaType == PICTURE) { 
    photoPickerIntent.setType("image/*"); 
    title = "GET_PICTURE"; 
}else if (this.mediaType == VIDEO) { 
    photoPickerIntent.setType("video/*");  
    title = "GET_VIDEO"; 
}else if (this.mediaType == AUDIO) { 
    photoPickerIntent.setType("audio/*");  
    title = "GET_AUDIO"; 
} 

Y Use los enlaces a continuación para referencia.

Pick Intent Example

+0

Lo he intentado pero me gustaría manejar solo archivos multimedia, no todos ellos –

+0

por favor vea mi respuesta editada. –

+0

así que, básicamente, no puedo configurar múltiples mimeTypes para un solo intento? –

Cuestiones relacionadas