Engprof
Engprof

Reputation: 191

Allowing the User to choose a picture from the pictures folder

I am trying to write code that will allow the user to choose a picture from the pictures folder and send that picture to the internet. I am new to Android so any help would be much appreciated.

Thanks in advance.

Upvotes: 3

Views: 2654

Answers (3)

Preet Sangha
Preet Sangha

Reputation: 65516

I've not done any Android programming but this looks very useful: OpenIntents (2010), file picker that can be incorporated into an app.

The original link is no longer available. But I've managed to find it from the 2010 Wayback Machine

Upvotes: 0

Shawn Lauzon
Shawn Lauzon

Reputation: 6282

You first need to start an Activity which asks the user to pick a picture. You next need to handle the result of that choice.

1: CHOOSE PICTURE

Intent choosePictureIntent = new Intent(MediaStore.ACTION_PICK, Images.Media.INTERNAL_CONTENT_URL);
startActivityForResult(choosePictureIntent, REQUEST_CHOOSE_IMAGE);

2: Handle the result of the Activity

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CHOOSE_IMAGE) {
        if (resultCode == RESULT_OK) {
            // send picture to Internet
        }
    }
}

How exactly you send the picture is a completely separate question.

Upvotes: 6

Kevin Gaudin
Kevin Gaudin

Reputation: 9945

You should look at this previous answer.

Upvotes: 0

Related Questions