Android Gps定位和網路定位
阿新 • • 發佈:2019-01-03
private LocationManager lm; private String provider; private LocationListener locationListener;
在oncreate();
lm= (LocationManager) getSystemService(Context.LOCATION_SERVICE);private void updataLocation() { List<String> list = lm.getProviders(true); if (list.contains(LocationManager.GPS_PROVIDER
在destroy裡面()
if (lm != null) { lm.removeUpdates(locationListener); }