How to simulate speed on Android emulator?
Is there a way to simulate speed on Android emulator?
[edit] The purpose of this to test the getSpeed() method
Example: I would like to set the device is going at 20 mi开发者_运维技巧les an hour.
Yes you can do that. If your using Eclipse to develop your app, you have to go to the DDMS perspective. There you should find a window called Emulator control. In this window you can send new geo locations (GPS coordinates) to your emulator or device. As you want to emaulte speed its better to use GPX or KML files. In this files you can define GPS coordinates and these coordinates are then read step by step. By choosing this coordinates appropriately you can simluate a constant speed.
The Location object has a method to set the speed of the device:
//the instance
Location location;
//retrieves the speed of the device
location.getSpeed()
// set the speed of the device of course for testing purporses, remember to
// remove this when deploying your appplication
location.setSpeed((float) 20.0)
If you want to simulate a change of speed over a time you can set a timer and decrease or increase the speed in that span of time, for example:
int secondsDelayed = 5;
new Handler().postDelayed(new Runnable() {
public void run() {
location.setSpeed((float) 50.0);
}
}, secondsDelayed * 1000);
This will incrase the speed to 50 km/p over a span of 5 seconds
I've faced the same problem with my high config pc have 3i 4GB
, but the emulator works so slow
I found something that worked for me and hope it may work for others i would love to share it here
i've just added Device ram size
to My existing AVD
and set the size to 1000MB
(Because i've enough to allot mind 4GB)
No the speed of my AVD
was ultimate hope it may help you.
精彩评论