Android Geofence не будет получать никаких обновлений перехода при путешествии более 10 км?

Я делаю приложение для Android, в котором я хотел бы генерировать сигнал тревоги/вызов, когда пользователь достигает пункта назначения. Я проверил свой код на разных расстояниях, и в результате тревога/вызов срабатывает только на небольшом расстоянии.

вот мой код: может ли кто-нибудь сказать мне, что мне нужно изменить?

MainActivity.java

                Geofence geofence = new Geofence.Builder()
                        .setCircularRegion(latlng1.latitude, latlng1.longitude, MyRadius)
                        .setRequestId(result)
                        .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
                        .setExpirationDuration(Geofence.NEVER_EXPIRE)
                        .build();

                myFences.add(geofence);
                googleApiClient = new GoogleApiClient.Builder(GpsAlarmMapsActivity.this)
                        .addApi(LocationServices.API)
                        .addConnectionCallbacks(GpsAlarmMapsActivity.this)
                        .addOnConnectionFailedListener(GpsAlarmMapsActivity.this)
                        .build();
                googleApiClient.connect();

GeofenceTransitionReceiver.java

public class GeofenceTransitionReceiver extends WakefulBroadcastReceiver {
int active_id = 0;
public static final String TAG = GeofenceTransitionReceiver.class.getSimpleName();

private Context context;
String code;
public static String Location_status;
Uri tone;
private DBHelper mydb1;
public GeofenceTransitionReceiver() {
}

@Override
public void onReceive(Context context, Intent intent) {
    Log.v(TAG, "onReceive(context, intent)");


    this.context = context;
    code = GpsAlarmMapsActivity.note;
    Log.i("Code....................", "code : " + code);
    GeofencingEvent event = GeofencingEvent.fromIntent(intent);

    if (event != null) {
        if (event.hasError()) {
            onError(event.getErrorCode());
        } else {
            int transition = event.getGeofenceTransition();
            if (transition == Geofence.GEOFENCE_TRANSITION_ENTER || transition == Geofence.GEOFENCE_TRANSITION_DWELL || transition == Geofence.GEOFENCE_TRANSITION_EXIT) {
                String[] geofenceIds = new String[event.getTriggeringGeofences().size()];
                for (int index = 0; index < event.getTriggeringGeofences().size(); index++) {
                    geofenceIds[index] = event.getTriggeringGeofences().get(index).getRequestId();
                }
                if (transition == Geofence.GEOFENCE_TRANSITION_ENTER || transition == Geofence.GEOFENCE_TRANSITION_DWELL) {

                    onEnteredGeofences(geofenceIds);
                    event=null;
                } else {
                    onExitedGeofences(geofenceIds);
                }
            }
        }
    }

}

protected void onEnteredGeofences(String[] geofenceIds) {
    for (String fenceId : geofenceIds) {
      //  Toast.makeText(context, String.format("Entered this fence: %1$s", fenceId), Toast.LENGTH_SHORT).show();
        Log.i(TAG, String.format("Entered this fence: %1$s", fenceId));
        mydb1 = new DBHelper(context.getApplicationContext());

            Location_status = "Entered";
            Log.i("on entered : ", "status " + Location_status);
            createNotification(fenceId, "Entered");



    }
}

protected void onExitedGeofences(String[] geofenceIds) {
    for (String fenceId : geofenceIds) {
        //  Toast.makeText(context, String.format("Exited this fence: %1$s", fenceId), Toast.LENGTH_SHORT).show();
        Log.i(TAG, String.format("Exited this fence: %1$s", fenceId));
        //  createNotification(fenceId, "Exited");
    }
}

protected void onError(int errorCode) {
    // Toast.makeText(context, String.format("onError(%1$d)", errorCode), Toast.LENGTH_SHORT).show();
    Log.e(TAG, String.format("onError(%1$d)", errorCode));
}

private void createNotification(String fenceId, String fenceState) {
    if (code == "alarm")
        tone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
    else
        tone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
    Intent notificationIntent = new Intent(context, StatPendingActivity.class);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
    notificationBuilder.setAutoCancel(true);
    notificationBuilder
            .setContentText("Title")
            .setSound(tone)
            .setContentTitle("Reached ! ")
            .setSmallIcon(R.drawable.ic_stat_action_room)
            .addAction(R.drawable.ic_stat_action_room, "Cancel", pendingIntent)
            .setColor(Color.argb(0x55, 0x00, 0x00, 0xff))
            .setTicker(String.format("%1$s Destination: %2$s", fenceState, fenceId));
    notificationBuilder.setContentIntent(pendingIntent);
    notificationManager.notify(R.id.notification, notificationBuilder.build());
}

}


person user3551647    schedule 28.08.2015    source источник
comment
Я думаю, вы достигли ограничения.   -  person Mr Neo    schedule 28.08.2015
comment
я должен изменить ключ API? есть ли способ продлить срок его службы?   -  person user3551647    schedule 28.08.2015
comment
Изменение ключа API не решит эту проблему, Google установил ограничение для каждого IP. Чтобы продлить срок службы, вы можете купить бизнес-пакет от Google. Надеюсь, это поможет вам.   -  person Mr Neo    schedule 28.08.2015
comment
У меня есть сомнения, если я пересек ограничение, короткое расстояние также не должно работать? я прав?   -  person user3551647    schedule 28.08.2015
comment
Да. после того, как ты тестировал на большом расстоянии, он все еще работал на коротком расстоянии, бро?   -  person Mr Neo    schedule 28.08.2015
comment
Да, он работает на короткие расстояния.   -  person user3551647    schedule 28.08.2015
comment
Я имею в виду, что вы тестируете на большом расстоянии, а вскоре будете тестировать на коротком расстоянии, все работает нормально?   -  person Mr Neo    schedule 28.08.2015
comment
да, тревога/вызов на короткое расстояние. когда я пытался с междугородной тревогой/вызовом, он не срабатывал, он также не отображал никаких ошибок. Я думаю, что геозона не контролирует.   -  person user3551647    schedule 28.08.2015
comment
Я нашел этот вопрос . Sr, потому что я не могу помочь вам с вашей проблемой   -  person Mr Neo    schedule 28.08.2015
comment
мой радиус 300 метров   -  person user3551647    schedule 02.09.2015
comment
Можете ли вы воспроизвести, как на устройстве, проехать более 10 км и создать отчет об ошибке. Потом посмотрите, нет ли там чего необычного. Проверьте метку времени и посмотрите, есть ли там что-нибудь.   -  person Kay_N    schedule 03.09.2015