Android locationManager.addProximityAlert是否需要位置侦听器

Android locationManager.addProximityAlert是否需要位置侦听器,android,locationmanager,proximity,Android,Locationmanager,Proximity,正如主题所说,我已经阅读了Android开发者指南,但并没有真正找到答案。如果您只想知道何时进入某个区域,则接近警报是否需要位置侦听器?我正在设置接近警报,如下所示: private void addProximityAlert(double latitude, double longitude) { Intent intent = new Intent(PROX_ALERT_INTENT); PendingIntent proximityIntent = Pe

正如主题所说,我已经阅读了Android开发者指南,但并没有真正找到答案。如果您只想知道何时进入某个区域,则接近警报是否需要位置侦听器?我正在设置接近警报,如下所示:

private void addProximityAlert(double latitude, double longitude) {

        Intent intent = new Intent(PROX_ALERT_INTENT);
        PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0,
                intent, 0);

        locationManager.addProximityAlert(latitude, longitude, POINT_RADIUS,
                PROX_ALERT_EXPIRATION, proximityIntent);

        IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);
        proxalert = new ProximityIntentReceiver();
        registerReceiver(proxalert, filter);
    }
addProximityAlert(SMASH_LAT, SMASH_LNG);
然后按如下方式调用该函数:

private void addProximityAlert(double latitude, double longitude) {

        Intent intent = new Intent(PROX_ALERT_INTENT);
        PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0,
                intent, 0);

        locationManager.addProximityAlert(latitude, longitude, POINT_RADIUS,
                PROX_ALERT_EXPIRATION, proximityIntent);

        IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);
        proxalert = new ProximityIntentReceiver();
        registerReceiver(proxalert, filter);
    }
addProximityAlert(SMASH_LAT, SMASH_LNG);
问题是,我是否需要以下内容

locationManager.requestLocationUpdates(
                // check every 10 minutes
                low.getName(), MINIMUM_TIME_BETWEEN_UPDATE,
                MINIMUM_DISTANCECHANGE_FOR_UPDATE, new MyLocationListener());


public class MyLocationListener implements LocationListener {
        @Override
        public void onLocationChanged(Location location) {
            Location pointLocation = retrievelocation();
            float distance = location.distanceTo(pointLocation);
            // txted.setText("Distance: " + distance);
        }

        @Override
        public void onStatusChanged(String s, int i, Bundle b) {
        }

        @Override
        public void onProviderDisabled(String s) {
            // try switching to a different provider
        }

        @Override
        public void onProviderEnabled(String s) {
            // try switching to a different provider
        }
    }

或者locationmanager是否已经处理网络/gps的位置更新,然后知道它何时在邻近区域?

无需担心,您确实需要它,但它可以保持为空。

抱歉@Evan R。您提出了问题,自己回答了。你从哪里找到解释的?你能说得更清楚些吗?有消息来源吗?