Build Uri of the format X:Y
android, uri
Solution
You can accomplish this by using a combination of the `parse` and `buildUpon` methods:
Uri geoLocation = Uri.parse("geo:0,0?").buildUpon()
.appendQueryParameter("q", location)
.build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
I learned this approach from the Udacity class "Developing Android Apps" although they do not fully explain it.
Problem
I'm trying to build a Uri the most correct way for an intent to query a location on a map. In the documentation for a Maps intent, it is states that Uris should be of the form: `geo:0,0?q=my+street+address`. I tried using Uri.Builder but found no method to specify the `"0,0"` part of the uri as Uri.Builder doesn't have a function to specify the path without prepending a '/'. Currently I'm stuck using the following code: ``` uri = new Uri.Builder() .scheme(URL_SCHEME_MAP) .encodedOpaquePart("0,0?q=" + query) .build(); ``` Which is OK, but not as nice as I'd like to have it. So I'm wondering if anyone knows of a better/nicer way to do this.