您的位置:首页 > 移动开发 > Android开发

Android模拟器中模拟GPS、打电话、…

2014-12-16 20:39 141 查看
在Android模拟器中模拟GPS、打电话、发短信……

首先,当然要打开模拟器

然后,连接模拟器

C:\Users\BillGates>telnet localhost 5554

Android Console: type 'help' for a list of commands

OK

其中5554为模拟器在本机的端口,可以使用adb devices查看:

C:\Users\BillGates>adb devices

List of devices attached

emulator-5554 device

连接模拟器后输入help命令查看帮助,输入命令、回车即可查看命令格式

geo是GPS、sms是发短信、gsm是打电话等等

1.用geo命令模拟发送GPS信号:

geo fix 经度 纬度

即相当于将手机移动到指定的经纬度

也可以用geo nmea模拟发送nmea内容

2.用SMS命令发短信

sms send 10086 haha

模拟10086给你的模拟器发送内容为“haha”的短信

3.用GSM命令打电话

gsm call 10086

模拟10086给你的模拟器打电话

………………………………………………

模拟器转换横屏 Ctrl+F11

把location api和map api结合起来,通过location api定位,然后在map api中显示地图:

mapView.setSatellite(false);

this.mapController = mapView.getController();

this.mapController.setZoom(15);

this.mapController.animateTo(this.getCurrentGeoPoint());//
通过动画方式移动到指定坐标

}
private GeoPoint getCurrentGeoPoint() {

LocationManager locationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);

Location
location = locationManager

.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

return new
GeoPoint((int) (location.getLatitude() * 1e6),

(int) (location.getLongitude() * 1e6));

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: