我有一个场景,该场景具有打开和关闭动作的位置。并且在这种情况下,如果当时孩子不在其位置服务中,我们会向其父设备推送一则有关其孩子位置的按钮。在这种情况下,我有一个问题是,如果孩子没有离开他们的移动GPS,但父母得到了通知。我想知道这将如何发生?而我该如何解决呢?
this.locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
this.isGPSEnabled = this.locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (this.isGPSEnabled) {
if (ContextCompat.checkSelfPermission(getApplicationContext(), "android.permission.ACCESS_FINE_LOCATION") == 0 || ContextCompat.checkSelfPermission(getApplicationContext(), "android.permission.ACCESS_COARSE_LOCATION") == 0) {
requestLocationUpdates();
this.gpsTrackerListener = new SPEEDTracker();
try {
this.locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, LOCATION_INTERVAL, LOCATION_DISTANCE,
this.gpsTrackerListener);
} catch (java.lang.SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "gps provider does not exist " + ex.getMessage());
}
Log.v("Gps", "is ON");
} else {
Log.v("Gps", " is OFF");
}
}
获取时没有错误。谢谢。