参考:
https://blog.csdn.net/diyangxia/article/details/90674393#2_26
//网络定位有两种方式,一种是WIFI小区定位、另一种方式是基站定位
//GPS定位依赖于太空中的卫星
public class MyLocation extends Activity{
LocationManager locationManager;
long minSecond = 2 * 1000;
long minDistance =0; //2;
Location location,lastLocation;
TextView textview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location);
textview=(TextView)findViewById(R.id.textview);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (!(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
|| locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))) {
Toast.makeText(this, "请打开网络或GPS定位功能!", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Settings.ACTION_LOCATION_SOU