获取用户的当前位置的步骤

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());


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