반응형
path에는 파일명이 들어간다. 예를들면 mnt/sdcard/camera/20110302.jpg
final Uri uriImages = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
mManagedCursor = getContentResolver().query(uriImages, null, "_data ='" + path + "'", null, null);
String imageUrl = "";
if (mManagedCursor != null)
{
mManagedCursor.moveToNext();
int id = mManagedCursor.getInt(0);
imageUrl = mManagedCursor.getString(0);
double g1 = mManagedCursor.getDouble(5);
double g2 = mManagedCursor.getDouble(6);
// 위도 경도가 0.0
latitude = String.valueOf(g1); // 위도
longitude = String.valueOf(g2); // 경도
Log.e("imageUrl", imageUrl);
mManagedCursor.close();
Uri uri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,id);
Bitmap selPhoto = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
options.inDither = true;
try {
selPhoto = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri),null, options);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
반응형
'Programming > Android' 카테고리의 다른 글
| [안드로이드] 이미지 파일 이름으로 URI 알아내기 (0) | 2013.07.10 |
|---|---|
| [안드로이드]파일명으로 URI 가져오기 (1) | 2013.06.18 |
| 안드로이드 UI & Layout (0) | 2013.04.12 |
| 안드로이드 Thread (0) | 2013.04.12 |
| [안드로이드] 이미지 관련, Bitmap, File, Image 관련 함수 정리 (1) | 2012.11.27 |