Skip to content

Instantly share code, notes, and snippets.

@csabafarkas
Created November 29, 2017 19:38
Show Gist options
  • Save csabafarkas/9379a5a769d263f9ba548f1be641784b to your computer and use it in GitHub Desktop.
Save csabafarkas/9379a5a769d263f9ba548f1be641784b 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