-1

I'm writing a code for my app, and i got stuck which trying to figure this out.

I want to call GALLERY from by app and then if the user selects an image, that image is brought back to my app for further actions instead of Gallery opening it.

Plz help me coding this, thanks in advance :)

4

2 に答える 2

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

SDカードで画像を取得するには

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();
            }
        }
    }
}
于 2012-06-09T14:34:10.637 に答える
0

答えはこちらをチェックしてください:ギャラリーから画像を選んでください

Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
//intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);
于 2012-06-09T13:16:21.680 に答える