我正在嘗試從攝像頭獲取拍攝圖片的位置。當我嘗試的Exif接口,但仍然photos.Please有人幫助返回空值...如何在Android中從攝像頭獲取當前拍攝圖片的位置
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, 100);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100 && resultCode == RESULT_OK && data != null) {
// Let's read picked image data - its URI
Uri pickedImage = data.getData();
// Let's read picked image path using content resolver
String[] filePath = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(pickedImage, filePath, null, null, null);
cursor.moveToFirst();
img1 = cursor.getString(cursor.getColumnIndex(filePath[0]));
ExifInterface exif = null;
try {
exif = new ExifInterface(img1);
} catch (IOException e) {
e.printStackTrace();
}
String lat = ExifInterface.TAG_GPS_LATITUDE;
String lat_data = exif.getAttribute(lat);
Log.e("MYDATA", lat_data);
cursor.close();
Toast.makeText(this, "Image Uploaded", Toast.LENGTH_SHORT).show();
}
分享你的代碼你試過的東西 – sumit
驗證你的文件真的有位置數據,大多數時候android設備的功能在默認情況下禁用相機應用程序。 – smora
其實我在Android設備中啓用地理定位。 –