开发者

Starting Google Maps as default activity

I want to start a Google Maps activity from a button click.

It works great:

Intent mapIntent = new Intent(Intent.ACTION_VIEW, url);
          mapIntent.setData(url);
          startActivity(mapIntent);

... but I really want to hide the intent chooser between Browser and Maps. I want to make the button open directly Google Maps.

I tried adding geo:0,0?q= as a prefix to the URL, and this works. But, for reasons I am not able to explain, I can't use this notation or my app would not work.

In other words: Can I invoke directly the Google Maps class 开发者_JAVA百科from its package to start it as an Intent?

Thank you.


The only way you would get "the intent chooser between Browser and Maps" is if your URL is an http:// URL. The proper way to open the Google Maps Android app is to use a geo: URL, not an http:// URL.

I tried adding geo:0,0?q= as a prefix to the URL, and this works. But, for reasons I am not able to explain, I can't use this notation or my app would not work.

Then write a different app. Or, open the Google Maps Web site rather than the Google Maps Android app.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜