2

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
  • 181
  • 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,163
  • 4
  • 34
  • 45
0

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

Preet Sangha
  • 62,844
  • 17
  • 138
  • 209
0

You should look at this previous answer.

Community
  • 1
  • 1
Kevin Gaudin
  • 9,837
  • 3
  • 31
  • 34