这是我到目前为止所尝试的内容。不知道我错了什么。适用于拍摄照片并将其设置为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();
}