2012-05-24 24 views
5

Tengo una aplicación en la que el usuario puede buscar imágenes, audio, video, archivos de doc desde sdcard y elegir 1 archivo para cargarlo en el servidor. Utilizando el siguiente código, puedo abrir la galería y seleccionar imagen, audio, video. Pero no tengo idea de cómo buscar documentos de la galería.Android ¿Cómo ver el documento desde sdcard en gallary?

Aquí está mi código.

Intent intent = new Intent(); 
    intent.setAction(Intent.ACTION_GET_CONTENT); 
    //intent.setType("video/*"); 
    //intent.setType("audio/*"); 
    //intent.setType("image/*"); 
    //**What I have to do for view document[.pdf/text/doc] file** 
    startActivityForResult(Intent.createChooser(intent, "Complete action using"), REQUEST_CODE); 

¿Alguien tiene alguna idea de cómo se puede lograr esto? Cualquier ayuda es muy apreciada.

Respuesta

0

la esperanza que esto ayudará a abrir un documento

public void openDOC(String name) { 


     File file = new File(Environment.getExternalStorageDirectory() + "/" 
       + bmodel.getUserMasterBO().getUserid() + "/" + name); 
     if (file.exists()) { 
      Uri path = Uri.fromFile(file); 
      Intent intent = new Intent(Intent.ACTION_VIEW); 
      intent.setDataAndType(path, "application/msword"); 
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

      try { 
       startActivity(intent); 
      } catch (ActivityNotFoundException e) { 
       Toast.makeText(this, "No Application Available to View DOC", 
         Toast.LENGTH_SHORT).show(); 
      } 
     } 

    } 
+0

Gracias por un swer. Quiero ver todo el archivo y luego de seleccionar la lista de formulario de un solo archivo. No quiero abrir el documento. Necesito solo un camino para poder subirlo al servidor. – Nik88

0

Intente lo siguiente,

File docfolder = new File(Environment.getExternalStorageDirectory() + "/" 
       + "Documents/"); 
File docList[] = docfolder.listFiles(); 
for(int i=0;i<docList.length;i++) 
{ 
     if (docList[i].exists()) { 
      Uri path = Uri.fromFile(docList[i]); 
      Intent intent = new Intent(Intent.ACTION_VIEW); 
      intent.setDataAndType(path, "application/msword"); 
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

      try { 
       startActivity(intent); 
      } 
      catch (ActivityNotFoundException e) { 

      } 
     } 
} 
1

tratar esta biblioteca aFileChooser sus finas

pls de trabajo ven esto link

Cuestiones relacionadas