I am looking for a light easy way, to pick an image from a gallery, and pass to another intent/activity the image selected.

This is what I have but I know it is wrong, I was just looking for some quick insight.

I know this opens up an image to be selected, but once it's selected, nothing happens, it does not load my intent. I am aware, from my belief once the image is selected it is just not dong anything and is returning true or w.e. when chosen and not providing anything, to which I ask if I need some more methods to be called that I haven't included? thank you.

Code:

item.getTitle().equals("Upload")) {

            // TODO might want to pass parameter of what fragment is loaded.
            // Switch to upload activity to allow for uploading of images.
            Intent uploadIntent = new Intent(this, UploadActivity.class);
            uploadIntent.setType("image/*");
            uploadIntent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(
                    Intent.createChooser(uploadIntent, "Select Picture"),
                    PICK_IMAGE);

            //startActivity(uploadIntent);
}
有帮助吗?

解决方案

I'm not sure I fully understand your requirements but if you're ok with launching the default system image gallery, then the following post may help you:

How to pick an image from gallery (SD Card) for my app?

The general idea is to request a new Activity handle an Intent requesting a result (startActivityForResult()). If an Activity is setup to receive the intent (ACTION_GET_CONTENT) then it will launch and handle your request. Once the request is complete, the Activity will return a result which your Activity will recieve in it's method

onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top