사용자가 응용 프로그램 내에서 일부 텍스트에 그림을 첨부 할 수있는 응용 프로그램을 개발 중이지만 사용자가 전화 갤러리에 액세스하여 사진을 응용 프로그램으로 가져와야합니다. 내 전화가 실행 중입니다. 2.3.5이 버전을 사용할 수 있습니까 ?? 그물에 대한 확실한 답을 찾지 못하는 것 !! 고마워 .....내 휴대 전화로 찍은 사진에 어떤 버전의 안드로이드를 사용할 수 있습니까?
0
A
답변
0
는 갤러리에서 이미지를 선택합니다
public class SelectPhotoActivity extends Activity {
private static final int SELECT_PICTURE = 1;
private String selectedImagePath="";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(intent, SELECT_PICTURE);
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE)
{
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
// here you can set the image
}
}
}
}
0
확실히 갤러리에서 이미지를 검색 할 수 있습니다. 코드를 게시 할 수 있습니까? 갤러리에서 이미지를 가져 오는 방법은 무엇입니까?