How to set the gps location

I get GPS coordinates from a third-party source. I want to set coordinates like my current location on my Android phone. After that, I want to open the google maps application and see that I'm exactly on the spot that I received from a third-party source.

Upvotes: 0

Views: 139

Answers (1)

Sagar
Sagar

Reputation: 24907

You cannot change the GPS co-ordinates of the device. What you can do is, display a map at a specified location as follows:

Uri gmmIntentUri = Uri.parse("geo:<latitude>,<longitude>");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
    startActivity(mapIntent);
}

You can also add query parameter z to indicate zoom level:

geo:<latitude>,<longitude>?z=10

Upvotes: 1

Related Questions