Googleのジオフェンシングサンプルコードで始まったアプリがあります。それは数日間うまくいく、と私は予想通りにすべての移行の意図を取得します。しかし、ちょっとした時間の後、3日のようなものが、これらの意図を得るのを止めると、理由はわかりません。Androidジオフェンスの最終的な移行インテントの取得を停止
私は私のフェンスを作成するときに、私はここで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);
}
}
これがなぜ機能しなくなるのでしょうか?
3日間のテスト中にデバイスを再起動していないことを確認してください。再起動時にジオフェンスを再登録するのを忘れていた可能性がありますか? 確認して更新してください。 – Anuj
android.intent.action.BOOT_COMPLETED – powder366