3

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.

Engprof
  • 191
  • 1
  • 3
  • 4

3 Answers3

6

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.

Shawn Lauzon
  • 6,234
  • 4
  • 35
  • 46
0

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

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
0

You should look at this previous answer.

Community
  • 1
  • 1
Kevin Gaudin
  • 9,927
  • 3
  • 32
  • 34