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
  • 372
  • 1
  • 7
  • 24

3 Answers3

1

You can use the DDMS tool to provide fake locations.

Moritz
  • 10,124
  • 7
  • 51
  • 61
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,514
  • 2
  • 23
  • 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,348
  • 6
  • 48
  • 57