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