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

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

2012-04-09 23:47 155 查看
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());
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  network service android