2013-05-30 104 views
2

我想從默認畫廊選擇文件,即圖像,視頻..但是當我打開使用以下功能的畫廊時,它也給我一些不必要的選擇文件選擇,如「文件管理器,OI文件管理器」。這些應用程序安裝在我的手機上,當我打開並選擇媒體文件時,我不希望這些應用程序。只打開默認畫廊

plz幫助

Intent intent = new Intent(Intent.ACTION_PICK); 
     intent.setType("video/*, images/*"); 
    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); 
     intent.setAction(Intent.ACTION_GET_CONTENT); 
     tartActivityForResult(Intent.createChooser(intent, "Select File"), 
         REQUEST_CODE); 
+0

你有什麼辦法解決? – shubomb

回答

1

使用此

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

感謝您的建議,我嘗試過,但仍然一樣。 – Nik

0
public void openGallery(int SELECT_FILE1) { 

    Intent intent = new Intent(); 
    intent.setType("image/*"); 
    intent.setAction(Intent.ACTION_GET_CONTENT); 
    startActivityForResult(
      Intent.createChooser(intent, "Select file to upload "), 
      SELECT_FILE1); 

} 

    // gallery................// 
protected void onActivityResult(int requestCode, int resultCode, 
     Intent imageReturnedIntent) { 
    super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 
    Uri selectedImageUri = null; 
    String filePath = null; 
    switch (requestCode) { 
    case SELECT_FILE1: 
     if (resultCode == Activity.RESULT_OK) { 
      selectedImage = imageReturnedIntent.getData(); 

      if (requestCode == SELECT_FILE1) { 
       selectedPath1 = getPath(selectedImage); 
       //mimagepath.setText(selectedPath1); 


      if (selectedPath1 != null) { 












      } 


      } 
     } 

     break; 


    } 

}