0

我是Android的新手。如何实现图像的地理标签?我自己尝试过,但没有得到预期的结果。我的代码是这样的:

@Override
    protected Dialog onCreateDialog(int id) {
       jpgDialog = null;;
       switch(id){
        case ID_JPGDIALOG:
        Context mContext = this;
        jpgDialog = new Dialog(mContext);
        jpgDialog.setContentView(R.layout.jpgdialog);
        exifText = (TextView) jpgDialog.findViewById(R.id.text);
        geoText = (TextView)jpgDialog.findViewById(R.id.geotext);
        bmImage = (ImageView)jpgDialog.findViewById(R.id.image);
        bmOptions = new BitmapFactory.Options();
        bmOptions.inSampleSize = 2;
        Button okDialogButton = (Button)jpgDialog.findViewById(R.id.okdialogbutton);
        okDialogButton.setOnClickListener(okDialogButtonOnClickListener);
        mapviewButton = (Button)jpgDialog.findViewById(R.id.mapviewbutton);
        mapviewButton.setOnClickListener(mapviewButtonOnClickListener);
        break;
        default:
        break;
        }
       return jpgDialog;
    }

请帮助我如何进行?

4

1 回答 1

0

首先需要获取位置信息:

http://developer.android.com/guide/topics/location/obtaining-user-location.html

然后,如果您的图像是 JPEG 文件,您可以在 EXIF 数据中嵌入坐标。使用 AndroidExifInterface注入或提取该信息。

http://developer.android.com/reference/android/media/ExifInterface.html

例子:

ExifInterface exifInterface = new ExifInterface(fileName);
exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, latitude);
exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, longitude);            exifInterface.saveAttributes();
于 2012-09-18T16:35:55.530 回答