Open gallery app from Android Intent

后端 未结 6 1200
难免孤独
难免孤独 2020-11-29 04:30

I\'m looking for a way to open the Android gallery application from an intent.

I do not want to return a picture, but rather just open the gallery to al

6条回答
  •  一个人的身影
    2020-11-29 05:23

    You can open gallery using following intent:

    public static final int RESULT_GALLERY = 0;
    
    Intent galleryIntent = new Intent(
                        Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(galleryIntent , RESULT_GALLERY );
    

    If you want to get result URI or do anything else use this:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    
        switch (requestCode) {
        case QuestionEntryView.RESULT_GALLERY :
            if (null != data) {
                imageUri = data.getData();
                //Do whatever that you desire here. or leave this blank
    
            }
            break;
        default:
            break;
        }
    }
    

    Tested on Android 4.0+

提交回复
热议问题