2

Is there any way to set location of an Android device by programming?

I mean, I want to manually provide latitude and longitude to my device(REAL, NO EMULATOR). My device doesn't have GPS Hardware.

Is it possible or we have to use something like Mock Location ?

Help me. Thanks.

Ravi
  • 352
  • 7
  • 23

3 Answers3

1

You can use the DDMS tool to provide fake locations.

Moritz
  • 9,828
  • 7
  • 47
  • 59
1

Try using GenyMotion and there is the guide you can use to test different location https://www.genymotion.com/#!/developers/user-guide

Suhail Mehta
  • 5,716
  • 2
  • 21
  • 37
1

If you are using Eclipse ,

Step 1:

you should go on Window > Open Perspective > DDMS

Step 2:

inside DDMS tab, you should click on Emulator Control

Step 3:

see Location Controls and send your desired latitude-longitude to the device

EDIT :

If you want to use Mock location programmatically, you may checkout Android-MockProviderGPS project which uses following permission and provide mock locations on each predefined interval from its .csv file from asset folder.

 <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
Community
  • 1
  • 1
Mehul Joisar
  • 15,218
  • 6
  • 47
  • 56