獲取用戶的當前位置的步驟

1、在AndroidManifest.xml當中聲明相應的權限

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

2、獲取LocationManager對象

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

3、選擇LocationProvider(常用的有兩種定位方式:1、GPS   2、NETWORK


4、綁定LocationListener對象

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,new TestLocationListener());


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章