开发者

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 m开发者_高级运维uch appreciated.

Thanks in advance.


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.


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


You should look at this previous answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜