• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Geo location using geo Uri

Pickles57

Lurker
Sep 13, 2017
1
0
I am trying to get my app to go to a specific latitude and longitude, but when it launches Google Maps or Google Earth it always defaults to my current location. Code is as follows:
Code
Button mapButton = (Button) findViewById(R.id.button2);
mapButton.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View view) {
String geoURI = "geo:37.422,-122.0847z=23";
Uri geo = Uri.parse(geoURI);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, geo);
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
\Code

How do I get it to override the default location and go to the coordinates I have hard coded above?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones