我是Android的新手。如何实现图像的Geo-tag?我亲自尝试但没有得到预期的结果。 我的代码就像:
@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;
}
请帮我怎么办?
答案 0 :(得分:0)
首先,您需要获取位置信息:
http://developer.android.com/guide/topics/location/obtaining-user-location.html
然后,如果您的图像是JPEG文件,则可以在EXIF数据中嵌入坐标。使用Android的ExifInterface
来注入或提取该信息。
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();