简体   繁体   中英

How do i link my android app to another built in application like google maps?

I would like to know if i can link my application with a app like google maps? For example If i create a button and onClick I go to Google maps app.So is there a way i can direct the onClick event of the button directly to the maps?If so how do I do it?

You can do it with intents, if you want to open google maps from your app, you can do it with this code:

String uri = "geo:"+ latitude + "," + longitude;
Intent myMapIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(myMapIntent);

You can find some useful info about that in the related Android Documentation

You can use

geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city

From the Android Developer guide

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr="+mylocation));
startActivity(intent);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM