-6
我想要獲取照片庫中的照片並將該照片添加到Android中的配置文件的代碼。如何在android中編寫從照片庫獲取照片的代碼?
我想要獲取照片庫中的照片並將該照片添加到Android中的配置文件的代碼。如何在android中編寫從照片庫獲取照片的代碼?
您可以啓動特定的意圖從設備獲取照片。
首先,定義意圖結果代碼的一個常數,例如:
private static final int SELECT_PICTURE_ACTIVITY_RESULT_CODE = 0;
然後,在必要時,調用意圖:
Intent photoPickerIntent = new Intent();
photoPickerIntent.setType("image/*"); // to pick only images
photoPickerIntent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(photoPickerIntent, SELECT_PICTURE_ACTIVITY_RESULT_CODE);
最後,實施Activity.onActivityResult(int, int, Intent)方法獲取的所述URI所選圖像:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case SELECT_PICTURE_ACTIVITY_RESULT_CODE:
Uri selectedImageUri = data.getData();
// deal with it
break;
default:
// deal with it
break;
}
}
}
u能plz向我總申請的GoogleMap – uma 2012-02-23 09:46:17
闡述你的問題:也許操作這個文檔描述可能會有幫助。什麼是配置文件? – 2012-02-23 10:04:46