Created
September 3, 2018 12:33
-
-
Save shubhamnikam/20d755d3dacaf3f8e34c989a268e2564 to your computer and use it in GitHub Desktop.
Implicit Intent - Open Map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
intentMaps.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
String latitude = "0"; | |
String longitude = "0"; | |
String query = "1600 Amphitheatre Parkway, CA"; | |
String zoomLevel = "10"; | |
Intent intent = new Intent(); | |
intent.setAction(Intent.ACTION_VIEW); | |
String data = String.format("geo:%s,%s?q=%s&z=%s", latitude, longitude, query, zoomLevel); | |
intent.setData(Uri.parse(data)); | |
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