允许用户选择图片文件夹中的图片 [英] Allowing the User to choose a picture from the pictures folder
本文介绍了允许用户选择图片文件夹中的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写code,将允许用户选择从照片文件夹中的图片,发送图片到互联网。我是新来的Android所以任何帮助将非常AP preciated。
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.
在此先感谢。
推荐答案
您首先需要启动一个活动询问用户选择一个图片。接下来需要处理的选择的结果。
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:选择图片
Intent choosePictureIntent = new Intent(MediaStore.ACTION_PICK, Images.Media.INTERNAL_CONTENT_URL);
startActivityForResult(choosePictureIntent, REQUEST_CHOOSE_IMAGE);
2:处理活动的结果
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.
这篇关于允许用户选择图片文件夹中的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文