Finding Current Location in android

后端 未结 5 1337
再見小時候
再見小時候 2021-01-24 13:51

I am trying to find current location, and this is my code.

 LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);        
           


        
5条回答
  •  -上瘾入骨i
    2021-01-24 13:53

    Location location =new Location(mlocManager.GPS_PROVIDER); 
    

    after writing this statement if you put your cursor over Location You will come to know extact meaning of this statement.

    As per Google Doc

    above Constructs a new Location. By default, time, latitude, longitude, and numSatellites are 0; hasAltitude, hasSpeed, and hasBearing are false; and there is no extra information.

    You need to fire requestLocationUpdate to get Lat & lon(If any).

    Also since you are running this example on Emulator.You will need to emulate send Lat & Lon manually.

    enter image description here

提交回复
热议问题