How to set the location manually in Android Studio emulator

前端 未结 4 831
甜味超标
甜味超标 2021-01-17 19:20

I have a project in which I need to get the location as India. But in my emulator I am not getting the location.

  • I need to get the location as India
  • <
相关标签:
4条回答
  • 2021-01-17 19:34

    In 2020 with Android Studio 3.6, the way I had to change the emulator location is slightly different than accepted answer. Here how it is:

    First,

    Second, Location is first menu item and it is selected by default. You have to select your location in the map and save that point.

    Third, select the saved point and press on select location button in bottom right corner.

    That's it, close that window. You are all done.

    Sometimes you may have to close the emulator and open (Not restart).

    0 讨论(0)
  • 2021-01-17 19:36

    You can set Location using Command prompt or ADB

    Set permissions in AndroidManifest.xml:

    Find the correct local port for your Android emulator:

    $ adb devices
      List of devices attached
      emulator-5554 device
    

    The port we are looking for is in this case 5554. Now connect via telnet:

    $ telnet localhost 5554
      Trying::1...
      Trying 127.0.0.1...
      Connected to localhost.
      Escape character is '^]'.
      Android Console: type 'help' for a list of commands
    

    Set your preferred location manually: You set the location with the geo fix command:

     geo fix $longitude $latitude
    

    For Example

    geo fix 2.169919 41.387917
    OK
    

    ANOTHER EASY WAY

    Open Android Device Monitor From Android Studio.

    Select the Emulator.

    Select Emulator Control

    In Emulator Control Select Location Control

    Select Manual

    In that Give your Longitude and Latitude

    0 讨论(0)
  • 2021-01-17 19:45

    In my case; until i login my Google account on emulator, location not changed. After login, it's changed. I think it's about Google Services.

    0 讨论(0)
  • 2021-01-17 19:56

    First of all,

    • Restart your emulator.
    • Go to More > Location. Enter your lat-long > Press SEND

    0 讨论(0)
提交回复
热议问题