Android - Unable to get the gps location on the emulator

后端 未结 4 1105
不知归路
不知归路 2020-12-06 18:12

i\'m tring to use the gps on the android emulator, i\'ve the following code:

public class NL extends Activity {

 private LocationManager locmgr = null;

 @O         


        
相关标签:
4条回答
  • 2020-12-06 18:36

    if all you what you described is done than maybe you are not probably not ur gps is on in emulator.go to setting:->Location and Security:->and use gps satelites should be checked


    edited:ithink you have to use location manager without criteria type.



    LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    
    loc=mlocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    

    ------than try to get long. and lat.

    0 讨论(0)
  • 2020-12-06 18:45

    Are you sure that your emulated device is actually supporting GPS? I think there was an extra option for this...

    This may help too:

    Thanks! To all: You can change the Build Target for your project any time in Eclipse: Right-click the project in Package Explorer, select Properties > Android and then check 'Google API' for Project Target. -- Developers working with non-English culture settings might notice that pressing the Send button in Location Controls does not send a new location to the Android emulator. It's fixed with the upcoming release 7 of the SDK tools; for a quick fix you can change your locale to 'en'. (See code.google.com/p/android/issues/detail?id=915 for details.) – Patrick de Kleijn

    source: GPS on emulator doesn't get the geo fix - Android

    0 讨论(0)
  • 2020-12-06 18:46

    FOUND THE SOLUTION:

    LocationManager.NETWORK_PROVIDER is WRONG.

    correction: LocationManager.GPS_PROVIDER

    0 讨论(0)
  • 2020-12-06 18:52

    Emulator just doesn't have any location at the beginning. According to the doc, 'getLastKnownLocation' method can return null, so it is ok. In that case you should wait for location updates (you can user requestLocationUpdates method from LocationManager). You can trigger location update on emulator's gps module by following command:

    adb -e emu geo fix 50 50
    
    0 讨论(0)
提交回复
热议问题