У меня есть приложение, которое начинается с примера кода Google geofencing. Он отлично работает в течение нескольких дней, и я получаю все возможности перехода, как я ожидаю. Однако, через некоторое время, что-то вроде 3 дней, приложение перестает получать эти намерения, и я не знаю почему.
Когда я создаю свои заборы, я устанавливаю продолжительность истечения срока действия в Geofence.NEVER_EXPIRE
Вот мой IntentService, где я получаю намерения перехода, прежде чем они перестанут работать:
public class ReceiveTransitionsIntentService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
Intent broadcastIntent = new Intent();
broadcastIntent.addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES);
// First check for errors
if (LocationClient.hasError(intent)) {
...handle errors
} else {
// Get the type of transition (entry or exit)
int transition = LocationClient.getGeofenceTransition(intent);
// Test that a valid transition was reported
if ((transition == Geofence.GEOFENCE_TRANSITION_ENTER)
|| (transition == Geofence.GEOFENCE_TRANSITION_EXIT)) {
// Post a notification
NEVER GETS HERE
} else {
...log error
}
}
}
}
Вот уместная часть манифеста:
<service
android:name="com.aol.android.geofence.ReceiveTransitionsIntentService"
android:exported="false" >
</service>
В моем классе GeofenceRequester он почти идентичен образцу кода. Вот соответствующие разделы:
// Get a PendingIntent that Location Services issues when a geofence transition occurs
mGeofencePendingIntent = createRequestPendingIntent();
// Send a request to add the current geofences
mLocationClient.addGeofences(mCurrentGeofences, mGeofencePendingIntent, this);
private PendingIntent createRequestPendingIntent() {
// Create an Intent pointing to the IntentService
Intent intent = new Intent(context, ReceiveTransitionsIntentService.class);
return PendingIntent.getService(
context,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT);
}
}
Кто-нибудь может понять, почему это перестало работать?