Skip to content

Instantly share code, notes, and snippets.

@csaba-farkas
Forked from csabafarkas/CreateMapUri.java
Last active September 7, 2018 14:09
Show Gist options
  • Save csaba-farkas/cdc8f2d68ddefe8a4757874e56d2a9e6 to your computer and use it in GitHub Desktop.
Save csaba-farkas/cdc8f2d68ddefe8a4757874e56d2a9e6 to your computer and use it in GitHub Desktop.
Build Uri with maps data
public void onClickOpenAddressButton(View v) {
String address = "Cork Ireland";
Uri.Builder builder = new Uri.Builder();
builder.scheme("geo")
.path("0,0")
.appendQueryParameter("q", address);
Uri addressUri = builder.build();
showMap(addressUri);
}
private void showMap(Uri mapUri) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(mapUri);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment