2012-06-09 33 views
-1

我正在为我的应用程序编写代码,并且我陷入了试图弄清楚这一点。呼叫画廊带回图像

我想通过应用程序,然后调用从GALLERY如果用户选择的图像,该图像是带回我的应用程序的进一步行动,而不是画廊开幕它

PLZ帮我编写此,在此先感谢:)

+1

请看右侧的相关问题。有很多问题可以解答你的问题。 – ariefbayu

回答

1
startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), SELECT_IMAGE); 

要在SD Card.Uri获取图像将

android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI

onActivityResult方法:

protected void onActivityResult(int requestCode, int resultCode, 
     Intent intent) { 
    super.onActivityResult(requestCode, resultCode, intent); 

    if (resultCode == RESULT_OK) { 
     Uri photoUri = intent.getData(); 

     if (photoUri != null) { 
      try { 
       Bitmap bitmap = MediaStore.Images.Media.getBitmap(this 
        .getContentResolver(), photoUri); 

       //Now you can upload this bitmap to server or do something else. 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 
    } 
} 
0

检查这里的答案:Pick an image from the Gallery

Intent intent = new Intent(Intent.ACTION_PICK); 
intent.setType("image/*"); 
//intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(intent, 1);