2012-05-24 15 views
5

मेरे पास ऐप है जिसमें उपयोगकर्ता एसडीकार्ड से छवि, ऑडियो, वीडियो, दस्तावेज़ फ़ाइल खोज सकता है और इसे सर्वर पर अपलोड करने के लिए 1 फ़ाइल चुन सकता है। नीचे कोड का उपयोग करके मैं गैलरी खोल सकता हूं और छवि, ऑडियो, वीडियो का चयन कर सकता हूं लेकिन मुझे नहीं पता कि गैलरी से दस्तावेज़ कैसे खोजें।एंड्रॉइड गैलरी में एसडीकार्ड से डॉक्टर को कैसे देखें?

मेरा कोड यहां है।

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); 

क्या किसी को पता है कि यह कैसे प्राप्त किया जा सकता है? कोई भी मदद बहुत ही सराहनीय होगी।

उत्तर

0

आशा यह आप किसी दस्तावेज़

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

के लिए धन्यवाद Swer। मैं सभी फाइल देखना चाहता हूं और इसके बाद मैं एकल फ़ाइल फॉर्म सूची का चयन करूंगा। मैं डॉक्टर को खोलना नहीं चाहता। मुझे बस एक रास्ता चाहिए ताकि मैं इसे सर्वर पर अपलोड कर सकूं। – Nik88

0

निम्नलिखित का प्रयास करें खोलने के लिए मदद मिलेगी,

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

इस पुस्तकालय aFileChooser कोशिश अपनी कार्यशील ठीक

कृपया इस link

देखना
संबंधित मुद्दे