Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7542265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:07:16+00:00 2026-05-30T08:07:16+00:00

i have coded an android application that will update GPS coordinates to the exif

  • 0

i have coded an android application that will update GPS coordinates to the exif of a image file.

i think that the image file exif was updated successfully as reading it will give me the GPS coordinates saved.

However, when i open up file explorer to view the image file in details, the GPS coordinate are still showing unknown. If i restart my phone, then the exif will show the updated GPS coordinate. EDIT: if i move the file to another folder, the info will be updated as well. so meaning i must phsycially do something to the image file before it will show.

anyone have any idea why is this so? and how do i solve it so it will update immediate without going to the file explorer to move the file or restart the phone?

Thank in advance!

edit: code added for the two main part

the codes for main class

public class ShowMapActivity extends MapActivity {

ExifInterface exifInterface;

private MapController mapController;
private MapView mapView;
private LocationManager locationManager;

private int Option;
private String selected_img;
float LatLong[] = new float[2];

public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.gpsmaploc); // bind the layout to the activity

        Bundle extras = getIntent().getExtras();
        if(extras !=null) {
            selected_img = extras.getString("selected_img");
            Option = extras.getInt("Option",0);
        }
        /*Intent cancelIntent = new Intent(this, A.class); 
         cancelIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(cncelIntent);*/

    // create a map view
    RelativeLayout linearLayout = (RelativeLayout) findViewById(R.id.mainlayout);
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    //mapView.setStreetView(true);
    mapController = mapView.getController();
    mapController.setZoom(20); // Zoon 1 is world view
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,
            0, new GeoUpdateHandler());

    updateExif(selected_img);

}

the method for updating exif

    public void updateExif(String file) { 
    Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

    if (location != null) {
        GeoPoint point = new GeoPoint(
                (int) (location.getLatitude() * 1E6), 
                (int) (location.getLongitude() * 1E6));

        String address = ConvertPointToLocation(point);
        String strLongitude = location.convert(location.getLongitude(), location.FORMAT_SECONDS);
        String strLatitude = location.convert(location.getLatitude(), location.FORMAT_SECONDS);
        String Text = "Lat=" + strLatitude  + " Long=" + strLongitude;
        String message = String.format(
                "Current Location \n%3$s \nLongitude: %1$s \nLatitude: %2$s \n"+Text,
                location.getLongitude(), location.getLatitude(),address
                );

        Toast.makeText(getApplicationContext(), message,
                Toast.LENGTH_LONG).show();
        try {
            exifInterface = new ExifInterface(file);

            String LATITUDE = degreeDecimal2ExifFormat(location.getLatitude());
            String LATITUDE_REF = "N";
            String LONGITUDE = degreeDecimal2ExifFormat(location.getLongitude());
            String LONGITUDE_REF = "E";

            String message2 = String.format(
                    "Longitude: "+ LONGITUDE + "\nLatitude: " + LATITUDE    );

            Toast.makeText(getApplicationContext(), message2,
                    Toast.LENGTH_LONG).show();

            exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, LATITUDE);
            exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, LATITUDE_REF);
            exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, LONGITUDE);
            exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, LONGITUDE_REF);

            exifInterface.saveAttributes();
            String exif = "";
              float[] LatLong = new float[2];
              if(exifInterface.getLatLong(LatLong)){
               exif += "\n saved latitude= " + LatLong[0];
               exif += "\n saved longitude= " + LatLong[1];
              }else{
               exif += "Exif tags are not available!";
              }
                Toast.makeText(getApplicationContext(), exif,
                        Toast.LENGTH_LONG).show();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:07:17+00:00Added an answer on May 30, 2026 at 8:07 am

    this code seem to solve my issue.

    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
    

    this will refresh the sdcard content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with my Android application. I need an application that will send
I have android application that is written regular way. layouts, java, APK. Now, depending
I'm working on an Android application that will send MMS internally without using the
I have been trying to create a simple application that will let the user
I am trying to develop an android application that will use the same MySQL
Here's the deal: I have an Android application that needs to call a web
I have an Android application (java) that was working fine when compiled with the
I have tried to create a android application that sends a serialzed object from
I have created an Android application that includes some unit conversion tools built into
I currently have an Android application that displays a schedule for a ferry boat.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.