我希望开发一个应用程序,打开应用程序后它将显示我的设备的当前位置。我想在不使用GPS的情况下完成这项任务。我已经编写了代码,但在打开地图时,它会显示美国的位置,而我希望它显示我的当前位置(即印度普纳)。请问如何获取我的近似正确位置?
以下是我的代码:
以下是我的代码:
protected void onCreate(Bundle arg0) {
// TODO Auto-generated method stub
super.onCreate(arg0);
setContentView(R.layout.main);
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener locListener = new LocationListener(){
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
String Text = "My current location is: " +
"Latitud = " + loc.getLatitude() +
"Longitud = " + loc.getLongitude();
Toast.makeText( getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
}