資源簡介
百度地圖定位實例
目前該實例實現了 獲取當前坐標以及具體位置的功能,但是 會不停的 獲取gps位置,這是百度sdk的問題
解決方法是:
//讀取當前坐標 final LocationClient mLocationClient = new LocationClient(mActivity); mLocationClient.setLocOption(GPSUtil.GetOnceOption()); mLocationClient.registerLocationListener( new BDLocationListener() { @Override public void onReceiveLocation(BDLocation location) { // TODO Auto-generated method stub if(location!=null){ longitude=location.getLongitude(); latitude=location.getLatitude(); } //這里是你取得經緯度后執行的業務邏輯操作 //.... //幾秒鐘之后自動停止獲取gps new Handler().postDelayed(new Runnable() { @Override public void run() { mLocationClient.stop(); // PromptUtil.showLongToast(mActivity, Longitude ""); } }, 1*1000); } } ); mLocationClient.start(); if (mLocationClient != null && mLocationClient.isStarted()) mLocationClient.requestLocation();
代碼片段和文件信息
/**?Automatically?generated?file.?DO?NOT?MODIFY?*/
package?com.example.bdlocationtest;
public?final?class?BuildConfig?{
????public?final?static?boolean?DEBUG?=?true;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-05-31?15:15??bdlocationtest\
?????文件?????????494??2015-05-31?15:19??bdlocationtest\.classpath
?????文件?????????850??2015-05-31?15:15??bdlocationtest\.project
?????目錄???????????0??2015-05-31?15:15??bdlocationtest\.settings\
?????文件?????????177??2015-05-31?15:15??bdlocationtest\.settings\org.eclipse.jdt.core.prefs
?????文件????????3021??2015-05-31?15:41??bdlocationtest\AndroidManifest.xm
?????目錄???????????0??2015-06-02?09:36??bdlocationtest\assets\
?????目錄???????????0??2015-05-31?22:14??bdlocationtest\bin\
?????文件????????3021??2015-05-31?15:41??bdlocationtest\bin\AndroidManifest.xm
?????文件??????296704??2015-05-31?22:14??bdlocationtest\bin\bdlocationtest.apk
?????目錄???????????0??2015-05-31?15:19??bdlocationtest\bin\classes\
?????目錄???????????0??2015-05-31?15:19??bdlocationtest\bin\classes\com\
?????目錄???????????0??2015-05-31?15:19??bdlocationtest\bin\classes\com\example\
?????目錄???????????0??2015-05-31?15:19??bdlocationtest\bin\classes\com\example\bdlocationtest\
?????文件?????????361??2015-05-31?15:19??bdlocationtest\bin\classes\com\example\bdlocationtest\BuildConfig.class
?????文件?????????364??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$attr.class
?????文件?????????485??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$dimen.class
?????文件?????????431??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$drawable.class
?????文件?????????450??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$id.class
?????文件?????????427??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$layout.class
?????文件?????????412??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$menu.class
?????文件?????????496??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$string.class
?????文件?????????455??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R$st
?????文件?????????753??2015-06-01?16:47??bdlocationtest\bin\classes\com\example\bdlocationtest\R.class
?????目錄???????????0??2015-05-31?15:19??bdlocationtest\bin\classes\com\study\
?????目錄???????????0??2015-05-31?15:26??bdlocationtest\bin\classes\com\study\bdlocationtest\
?????文件????????2345??2015-05-31?22:21??bdlocationtest\bin\classes\com\study\bdlocationtest\LocationApplication$MyLocationListener.class
?????文件????????1512??2015-05-31?22:21??bdlocationtest\bin\classes\com\study\bdlocationtest\LocationApplication.class
?????文件????????2256??2015-05-31?22:13??bdlocationtest\bin\classes\com\study\bdlocationtest\MainActivity.class
?????文件??????707200??2015-05-31?22:14??bdlocationtest\bin\classes.dex
?????目錄???????????0??2015-05-31?15:32??bdlocationtest\bin\dexedLibs\
............此處省略59個文件信息
評論
共有 條評論