开发者

Launching the google maps app from within my app

I've been searching around the internet, the android dev guide and stackoverflow for almost 2 hours now and can't seem to find the answer that I'm looking for so I'm just going to go ahead and ask.

I'm build开发者_运维问答ing an app that has a button called "Find it nearby" that's only purpose is when the user clicks on it, it will call over to the Google maps app using some perimeters that I will set in place. I do not want to just use a mapview from within my app, I want to launch and use the full google maps app itself.

Now to be very specific, I have all the permissions needed and the maps url inside of my manifest. I have all of my application code set in place (buttons, xml, classes etc) and they are all ready and usable other then the code that will launch the Google maps app and once again, I have looked on here, google searching, various books, and the android dev guide to no avail.

I just need to know what the code is that I need to put into my app that will enable it to launch the actual, full google maps app from within my app and NOT a mapview. Any assistance would be greatly welcomed


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

At Android SDK documentation, you can see the below options you can try in the above uri string value.

Launching the google maps app from within my app

For more info refer this: http://developer.android.com/guide/appendix/g-app-intents.html


Use the following code

String url = "geo:0,0?q=Coffee Shop";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));
startActivity(intent);

This will use the original google Map Application for current location and if you want to search for a particular place then use url as "geo:0,0?q=Coffee Shop Near LocationName".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜