could not write location info
<p>I'm trying to write location info to a picture taken through my application using camera and returning control to the application. It is working perfectly fine while running on emulator but when i run it on my Samsung infuse device location info are not captured. Please let me know what i'm doing wrong. </p>

<p>Method to initiate the intent</p>

<pre><code>private void takePicutre(){
    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

    fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); 
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 
    startActivityForResult(intent, 2);
}
</code></pre>

<p>To Create a file Uri for saving an image</p>

<pre><code>private static Uri getOutputMediaFileUri(int type){
      return Uri.fromFile(getOutputMediaFile(type));
}
</code></pre>

<p>To Create a File for saving an image</p>

<pre><code>private static File getOutputMediaFile(int type){
    File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES), "MyApp");

    if (! mediaStorageDir.exists()){
        if (! mediaStorageDir.mkdirs()){
            return null;
        }
    }
        String timeStamp = new
          SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());

    File mediaFile;
    if (type == MEDIA_TYPE_IMAGE){
        mediaFile = new File(mediaStorageDir.getPath() + File.separator +
        "IMG_"+ timeStamp + ".jpg");
    } else {
        return null;
    }

    return mediaFile;
}
</code></pre>

<p>Writing EXIF data</p>

<pre><code>@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

ExifInterface exif;
double latitude = cls_raw_lat;
double longitude = cls_raw_lon;
try {
 exif = new ExifInterface(fileUri.getPath());
 int num1Lat = (int)Math.floor(latitude);
 int num2Lat = (int)Math.floor((latitude - num1Lat) * 60);
 double num3Lat = (latitude - ((double)num1Lat+ ((double)num2Lat/60))) * 3600000;

 int num1Lon = (int)Math.floor(longitude);
 int num2Lon = (int)Math.floor((longitude - num1Lon) * 60);
 double num3Lon = (longitude - ((double)num1Lon+((double)num2Lon/60))) * 3600000;

exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE,
num1Lat+"/1,"+num2Lat+"/1,"+num3Lat+"/1000");                   

exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE,  
num1Lon+"/1,"+num2Lon+"/1,"+num3Lon+"/1000");


if (latitude &gt; 0) {
    exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, "N"); 
} else {
    exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, "S");
}
if (longitude &gt; 0) {
    exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, "E");    
} else {
   exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, "W");
}

exif.saveAttributes();

} catch (IOException e) {
Toast.makeText(this, "Error: "+e.getMessage(),
Toast.LENGTH_LONG).show();  
}       

}
</code></pre>
