0

I am a new guy in Android. How to implement the Geo-tag for images? I have tried by myself but not getting expected result. My code is like:

@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;
    }

Please help me how to proceed?

sundar
  • 45
  • 1
  • 6

1 Answers1

0

First you need to obtain the location information:

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

Then, if your images are JPEG files, you can embedded the coordinates in the EXIF data. Use Android's ExifInterface to inject or extract that information.

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

Example:

ExifInterface exifInterface = new ExifInterface(fileName);
exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, latitude);
exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, longitude);            exifInterface.saveAttributes();
Filipe Batista
  • 1,862
  • 2
  • 24
  • 39