How to set the location manually in Android Studio emulator

[亡魂溺海] 提交于 2019-12-23 11:51:25

问题


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
  • when I take the google maps from my emulator, it is showing the current location in middle of the sea.

    API level I am using is 27.
    Emulator I use is Nexus 5x.
    

how to get the current position in this Emulator and also manually.

I tried to edit the location in Emulator and tried to give the latitude and longitude but it is not working.


回答1:


First of all,

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




回答2:


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



来源:https://stackoverflow.com/questions/47528006/how-to-set-the-location-manually-in-android-studio-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!