2012-02-27 49 views
-3

我怎样才能让我的当前位置在AlertDialog我如何在警报对话框中获得当前位置?

String text = String.format("Lat:\t %f\nLong:\t %f\nAlt:\t %f\nBearing:\t %f", location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getBearing()); 
this.locationText.setText(text); 

THX的帮助

+1

请改善您的问题。你没有告诉我们你曾经尝试过什么,在标题和身体上发布相同的问题并不是一个好的方法。请阅读http://stackoverflow.com/faq了解更多信息。 – WarrenFaith 2012-02-27 13:04:04

回答

1

谷歌提供大量的documentation在这个问题上。

要记住的重要一点是,获取用户当前位置可能需要时间,如果他们使用GPS,则需要很长时间。您可以采取多种方法,但是如果您想快速显示带有位置信息的对话框,则应该使用'getLastKnownLocation',它可能不准确,但速度会很快。