GPS: triangle positioning, positioning accuracy, the minimum accuracy of about 15 meters, shortcomings--positioning speed slow, boot time long base station: the use of triangular positioning method, positioning fast, low positioning accuracy of 30 meters to 2 km network: using IP to locate; AGAP: Network Assistant location System ; now locate on the phone in this way; Add permissions to the manifest file:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 注:最佳定位方式通过GPS、
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>注:网络定位
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>注:车载系统定位
Permissions annotations: Allows an app to access precise location from location sources such as GPS, cell towers, and Wi-Fi. (Android.permission.ACCESS_FINE_LOCATION)allows an app to access approximate location derived from network location sources such as cell towers and Wi-Fi (Android.permission.ACCESS_COARSE_LOCATION)allows an application-to-create mock location providers for testing (Android.permission.ACCESS_MOCK_LOCATION)
Locating api:1 and getting Locationmanager objects through system services
LocationManager lm=(LocationManager)getSysyrmService
2. By callingRequestlocationupdates (Stringprovider, long mintime, float mindistance,Locationlistenerlistener) to achieve positioning
lm.requestLocationUpdates("gps",0,0,new MyLocationLiseter());
Parameter comment: provider: Get location information: gps\ base station \ Network mintime: At least how long it takes to get information back mindistance: At least move multiple long distances to regain information Listener: Listener for position changeCustomizing the Locationlistener and serializing specific positioning information to a local
private class MyLocationLiseter implements LocationListener{
/**
* 位置发生变化调用这个方法
*/
@Override
public void onLocationChanged(Location location) {
//维度
double w = location.getLatitude();
//经度
double j = location.getLongitude();
// 精确度
double a = location.getAccuracy();
String l = w+","+j+ "," +a;
System.out.println("=================="+l);
SharedPreferences sp = getSharedPreferences("config", Context.MODE_PRIVATE);
Editor editor = sp.edit();
editor.putString("location", l);
editor.commit();
}
/**
* 某一种定位方式的状态发生变化调用这个方法
* 打开--关闭
* 关闭--打开
*/
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
/**
* 某一种定位方式的可用时发生变化时调用这个方法
* 不可用--可用
*/
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
/**
* 某一种定位方式的不可用时发生变化时调用这个方法
* 可用--不可用
*/
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
}
From for notes (Wiz)
How mobile phones are positioned