我需要在新的Thread()。start()中使用requestLocationUpdates(),因为我必须获取计时器间隔。
try {
JSONObject response = new JSONObject(API.onRequest("session", new JSONObject().put("uuid", Settings.Secure.ANDROID_ID)));
if (response.getBoolean("result")) {
token = response.getString("token");
int interval = response.getInt("interval");
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, interval, 0, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, interval, 0, this);
}
Toast.makeText(LocationService.this, response.getString("detail"), Toast.LENGTH_LONG).show();
//return;
} catch (Exception ignored) {
}