How to emulate GPS location in the Android Emulato

2018-12-31 02:23发布

I want to get longitude and latitude in Android emulator for testing.

Can any one guide me how to achieve this?

How do I set the location of the emulator to a test position?

30条回答
路过你的时光
2楼-- · 2018-12-31 02:52

If the above solutions don't work. Try this:

Inside your android Manifest.xml, add the following two links OUTSIDE of the application tag, but inside your manifest tag of course

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" ></uses-permission>
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
查看更多
泛滥B
3楼-- · 2018-12-31 02:55

For Android Studio users:

run the emulator,

Then, go to Tools -> Android ->Android device monitor

open the Emulator Control Tab, and use the location controls group.

查看更多
有味是清欢
4楼-- · 2018-12-31 02:55

Using the "geo" command in the emulator console

To send mock location data from the command line:

  1. Launch your application in the Android emulator and open a terminal/console in your SDK's /tools directory.

  2. Connect to the emulator console:

    telnet localhost 5555 (Replace 5555 with whatever port your emulator is running on)

  3. Send the location data: * geo fix to send a fixed geo-location.

    This command accepts a longitude and latitude in decimal degrees, and an optional altitude in meters. For example:

    geo fix -121.45356 46.51119 4392
    
查看更多
牵手、夕阳
5楼-- · 2018-12-31 02:58

I use eclipse plug DDMS function to send GPS. enter image description here

查看更多
琉璃瓶的回忆
6楼-- · 2018-12-31 02:58

I was unable to get a GPS fix on the emulator when emulator was running Android image without Google APIs. As soon as I changed the image to contain Google APIs all of the here mentioned ways to get a GPS fix worked.

Make sure you select an image with Google APIs when creating AVD.

查看更多
梦醉为红颜
7楼-- · 2018-12-31 02:58

In eclipse:

You may have to drag the DDMS window down. 'Location Controls' is located under 'Telephony Actions' and may be hidden by a normally sized console view ( the bar with console, LogCat etc may be covering it!)

~

查看更多
登录 后发表回答