这是我到目前为止所尝试的。不知道我做错了什么。可以很好地拍照并将其设置为 ImageView,但是当我添加尝试获取位置的代码时会崩溃。
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == ACTION_IMAGE_CAPTURE) {
new Thread(new Runnable() {
public void run() {
final Bitmap bm = (Bitmap) data.getExtras().get("data");
Uri uri = data.getData();
Cursor cursor = getBaseContext().getContentResolver().query(uri, new String[] {android.provider.MediaStore.Images.ImageColumns.LATITUDE,
android.provider.MediaStore.Images.ImageColumns.LONGITUDE }, null, null, null);
if(cursor.moveToFirst()){
int latIndex = cursor.getColumnIndex(android.provider.MediaStore.Images.ImageColumns.LATITUDE);
int lonIndex = cursor.getColumnIndex(android.provider.MediaStore.Images.ImageColumns.LONGITUDE);
double longitu = cursor.getDouble(lonIndex);
double latitu = cursor.getDouble(latIndex);
Log.d("picloc", longitu + " "+latitu);
}
iv.post(new Runnable() {
public void run() {
iv.setImageBitmap(bm);
}
});
}
}).start();
}