解决方案 »
- 谁有做过android视频播放器
- NDK 的Program received signal SIGILL, Illegal instruction 错误
- Android的post请求问题,急!!!!!!在线等
- android调用webservice
- android连接本地计算机tomcat服务器(高手进)急!!!!
- TabHost问题求高手
- 结帖率100% 再次发问 有关于android截取图像的问题 绝对有挑战
- 请问Android下jni中怎么实现转码
- android应用之前的跳转传值
- 如何设置点击背景时可以将程序隐藏?
- 求教 ProtoBuf 交互传值 socket 发包 C++ 传stream 到 java 反序列化失败 问题
- 安卓自启动c++程序
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote" >
</service>
MapView mMapView;
MapController mc; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* mBMapMan = new BMapManager(getApplicationContext());
* mBMapMan.init(null);
*/
setContentView(R.layout.activity_main);
/*
* mMapView = (MapView) findViewById(R.id.mp); GeoPoint center = new
* GeoPoint((int) (39.915 * 1E6), (int) (116.404 * 1E6)); mc =
* mMapView.getController();
*
* mc.setCenter(center); mc.setZoom(12);
*
* mMapView.setBuiltInZoomControls(true);
* mMapView.setDoubleClickZooming(true); mMapView.setTraffic(true);
* mMapView.showScaleControl(true); mMapView.refresh();
*/ /**
* 定义定位端
*/
// LocationClient locationClient = new
// LocationClient(MainActivity.this);
LocationClient locationClient = new LocationClient(
getApplicationContext());
locationClient.registerLocationListener(new BDLocationListener() { @Override
public void onReceiveLocation(BDLocation location) {
// TODO Auto-generated method stub
if (location == null) {
return;
} StringBuffer sb = new StringBuffer();
sb.append("time:");
sb.append(location.getTime());
sb.append("\n"); sb.append("error type:");
sb.append(location.getLocType());
sb.append("\n"); sb.append("latitude : ");
sb.append(location.getLatitude());
sb.append("\n"); sb.append("lontitude : ");
sb.append(location.getLongitude());
sb.append("\n"); sb.append("radius : ");
sb.append(location.getRadius());
sb.append("\n");
if (location.getLocType() == BDLocation.TypeGpsLocation) {
sb.append("\nspeed : ");
sb.append(location.getSpeed());
sb.append("\nsatellite : ");
sb.append(location.getSatelliteNumber());
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
sb.append("\naddr : ");
sb.append(location.getAddrStr());
} mc.animateTo(new GeoPoint((int) (location.getLatitude()),
(int) (location.getLongitude())));
logMsg(sb.toString());
} @Override
public void onReceivePoi(BDLocation poiLocation) {
// TODO Auto-generated method stub
if (poiLocation == null) {
return;
}
StringBuffer sb = new StringBuffer(256);
sb.append("Poi time : ");
sb.append(poiLocation.getTime());
sb.append("\nerror code : ");
sb.append(poiLocation.getLocType());
sb.append("\nlatitude : ");
sb.append(poiLocation.getLatitude());
sb.append("\nlontitude : ");
sb.append(poiLocation.getLongitude());
sb.append("\nradius : ");
sb.append(poiLocation.getRadius());
if (poiLocation.getLocType() == BDLocation.TypeNetWorkLocation) {
sb.append("\naddr : ");
sb.append(poiLocation.getAddrStr());
}
if (poiLocation.hasPoi()) {
sb.append("\nPoi:");
sb.append(poiLocation.getPoi());
} else {
sb.append("noPoi information");
}
mc.animateTo(new GeoPoint((int) (poiLocation.getLatitude()),
(int) (poiLocation.getLongitude())));
logMsg(sb.toString());
}
}); /**
* 设置定位信息
*/
LocationClientOption option = new LocationClientOption();
// 设置定位模式
// 定位模式(高精度定位模式,低功耗定位模式和仅用设备定位模式),返回坐标类型,是否打开GPS等等。
option.setLocationMode(LocationMode.Device_Sensors); // 设置发起定位请求的间隔时间为5000ms
option.setScanSpan(5000); // 返回的定位结果包含地址信息
option.setIsNeedAddress(true); // 返回的定位结果包含手机机头的方向
option.setNeedDeviceDirect(true);
//打开gps
option.setOpenGps(true); locationClient.setLocOption(option); locationClient.start();
boolean ss = locationClient.isStarted();
/**
* 发起定位请求
*/
if (locationClient != null)
if (locationClient.isStarted()) {
locationClient.requestLocation();
} else
Log.d("LocSDK3", "locClient is null or not started"); } public void logMsg(String string) {
// TODO Auto-generated method stub
Log.v("locationClient:", string);
}
}