終了時に
geoFence
を更新する必要があります。そのために私はその時点で現在の場所が必要です。私のアプリがを閉じているときGeofence.GEOFENCE_TRANSITION_EXITの現在の位置を取得
私はonLocationChanged
のリスナーを持っていません。そして、 geoFenceを更新するには私の所在地が必要です。細かい作業
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
int resultCode = bundle.getInt("done");
if (resultCode == 1) {
if(!MainActivity.isGeoFenceAdded){
updateGeoFencesOnCurrentExit();//I need current location here
}
}
}
}
};
すべてのものMainActivityにGeofence.GEOFENCE_TRANSITION_EXIT
public void broadcastUpdateGeoFences() {
MainActivity.isGeoFenceAdded = false;//It tells to update geoFence
Intent intent = new Intent(Constants.RECEIVER_GEOFENCE);
intent.putExtra("done", 1);
sendBroadcast(intent);
}
放送受信機での現在位置を取得する彼らのどのような方法があります。しかしアプリケーションが終了したときに終了時にcurrentLocationを渡す方法が見つかりません。
private void updateGeoFencesOnCurrentExit(Location currentLocation){
locationHandler.updateGeoFences(currentLocation);
}
これにインテントサービスを使用していますか? – mechdon
はい私はそれが放送受信機であるべきであると私は知っている – Nepster
あなたの実際のジオフェンスの要求はどこですか? –