打开图像形式built_in画廊

问题描述:

我已阅读此链接:以编程方式在Android内置画廊应用程序中打开图像Get/pick an image from Android's built-in Gallery app programmatically,代码看起来不错。打开图像形式built_in画廊

结果与以下图像:http://i.stack.imgur.com/vz3S8.png,但这不是我想要的结果。

我想打开画廊类似于:http://i.stack.imgur.com/ZoUvU.png。 我想选择图片文件夹中的图片库。

你知道如何修改代码吗?

我用:

Intent intent = new Intent(); 
intent.setComponent(new ComponentName("com.android.gallery", "com.android.camera.GalleryPicker")); 

// intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 

Log.i("aa","adafdsfa"); 
startActivityForResult(intent, 1); 

通过我得到的文件夹,画廊,但我不能让PIC路径。

File dir = new File(Environment.getExternalStorageDirectory().toString() + "/sdcard/yourfolder"); 
     Log.d("File path ", dir.getPath()); 
     String dirPath=dir.getAbsolutePath(); 
     if(dir.exists() && dir.isDirectory()) { 
      Intent intent = new Intent(Intent.ACTION_VIEW); 
      // tells your intent to get the contents 
      // opens the URI for your image directory on your sdcard 
          //its upto you what data you want image or video. 
      intent.setType("image/*"); 
     // intent.setType("video/*"); 
      intent.setData(Uri.fromFile(dir)); 
     // intent.setType("media/*"); 
     // intent. 
      startActivityForResult(intent, 1); 
     } 
     else 
     { 
      showToast("No file exist to show"); 
     } 


     protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    // TODO Auto-generated method stub 
    super.onActivityResult(requestCode, resultCode, data); 

    if (requestCode == 1) { 
     if (data==null) { 
      showToast("No image selected"); 
      //finish(); 
     } 
     else 
     { 
     Uri selectedImageUri = data.getData(); 

     // String filemanagerstring = selectedImageUri.getPath(); 

     //MEDIA GALLERY 
     String selectedImagePath = getPath(selectedImageUri); 

     if(selectedImagePath!=null) 
     { 
      Intent intent = new Intent(); 
      intent.setAction(Intent.ACTION_VIEW); 
      intent.setData(selectedImageUri); 
      startActivity(intent); 
     } 

     else 
     { 
      showToast("Image path not correct"); 
     } 


    } 
     } 

}