2012-06-09 4 views
-1

내 앱용 코드를 작성 중이며이를 파악하려고 노력 중이다.갤러리를 불러 이미지를 가져 오기

나는 사용자가 이미지를 선택하면 응용 프로그램에 의해 다음에서 GALLERY을 호출 할, 그 이미지를 열어 추가 작업 대신 갤러리 다시 내 응용 프로그램에 가져 이다.

은 Plz은, 날이 코딩 미리 감사드립니다 :) 답변 여기

+1

오른쪽 사이드 바에있는 관련 질문을보십시오. 너에게 답이있는 질문들이있다. – ariefbayu

답변

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

될 것

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

확인하는 데 도움 : SD Card.Uri에서 이미지를 가져올 수 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);