shadowpiece
shadowpiece

Reputation: 31

How to send "geo fix" command to real device of Android?

First,thank you for your attention to my question

I'm planning to design an Android GPS locating application

here are my difficulties and situations

(1)my computer hardware has been out of date for a long time and running an android emulator for debugging is really time-costing,thus i bought a real device(android cellphone) one week ago,in the aim of replacing emulator during debugging

(2)i know how to send location datas to an emulator via "DDMS/Emulator Control/Location Controls",but it is disabled for a real device

(3)i am programming indoor,thus using physical gps locating function is not acceptable(even if i turn on "a-gps")

(4)i have found another topic here: Android mock location on device? however,i can't open the detail links,like "Andrews link"," http://dehuysser.appspot.com/blog/android-developer-shell-released"

I guess these web sites are forbidden by my country......


Here are my questions:

(A)i have found some codes of making mock loation datas ,but these codes can not activate "onLocationChanged" function

However, i wonder if there is a way to send locating datas from PC to real device via USB port(i'm in USB debugging mode), just like sending locations from DDMS to emulator?

(B)i've got the information that, it is possible to send "geo fix" command to emulator as well as to a real device, by "telnet localhost ", but how to check out the port number occupied by my real device?

i know that 5554 port is used for a emulator,but what about the real device?

i've tried to command "netstat" in terminal, but it's a shame to say that i don't know which port is for my android phone......

(C)If my (A)(B) question is not practical,then what's "settings/applications/development/allow mock location" used for?

Please help me, and thank you for your answer!

Upvotes: 3

Views: 9422

Answers (2)

Reno
Reno

Reputation: 33792

The easiest way of using mock data is using the mock test location provider API. It's at the bottom of the documentation page. I've tried it out and location is received in the onLocationChanged callback. Here is some code that you can try out.

The port used by adb is usually 5037.

Upvotes: 1

luv
luv

Reputation: 432

I have wrote an app exactly for this (this functionality is not available on phones by default) - it's open source and provides exactly the same interface as the emulator (telnet to :5554 and run "geo fix ..." or "geo nmea"): in app store MockGeoFix

Upvotes: 2

Related Questions