How to emulate GPS location in the Android Emulator?

前端 未结 30 2401
天命终不由人
天命终不由人 2020-11-21 22:15

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

30条回答
  •  后悔当初
    2020-11-21 22:48

    No one here mentioned the built in solution of the emulator itself, so for future visitors, I'd like to share it with visuals.

    First, run your Android Emulator and click on the menu button (3 dots) shown below:

    Then from the left pane, select Location and change the coordinates according to your needs. After pressing Send button, changes will immediately take effect (I recommend you to open up Google Maps for better understanding).

    Android Studio Version: 2.3.3

    In addition, to make your different locations coming to your application in real time, you can use GPX file. It's very easy to create this file from Google Map direction link:

    1. Go to google map, choose a location, then press "Directions" and enter the second location.
    2. After route is created, copy a link from the browser
    3. Go to this website: https://mapstogpx.com and paste the link to "Let's Go" box
    4. Press the "Let's Go" button and GPX file will be downloaded

    Use "Load GPS/KML" button to load the created file to your emulator, choose speed, and press green play button on the bottom. Locations will be sent in real time as shown on the picture below.

提交回复
热议问题