は私のジオフェンスが正常に動作してそれ以外の場合は、他のすべての動作を停止に変更しました。私は私のジオフェンスを再登録しようとするところ は、ここでは放送受信機の私のコードです。?プロバイダで
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
public class LocationProviderChangedReceiver extends BroadcastReceiver implements GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener,ResultCallback<Status> {
int i=0;
protected GoogleApiClient mGoogleApiClient;
Geofence geofence;
Context context;
@Override
public void onReceive(Context context, Intent intent) {
i=i++;
this.context=context;
Toast.makeText(context,"Provider changed ,Geofencing restarted.",Toast.LENGTH_LONG).show();
Log.wtf("senpai","oooooo"+i);
LatLng latLng=new LatLng(28.5795613,77.3136267);
geofence=new Geofence.Builder()
.setRequestId("x").setCircularRegion(latLng.latitude,latLng.longitude, Constants.GEOFENCE_RADIUS_IN_METERS)
.setExpirationDuration(Constants.GEOFENCE_EXPIRATION_IN_MILLISECONDS)
.setLoiteringDelay(500)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT|Geofence.GEOFENCE_TRANSITION_DWELL)
.build();
mGoogleApiClient = new GoogleApiClient.Builder(context)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
@Override
public void onConnected(@Nullable Bundle bundle) {
try {
LocationServices.GeofencingApi.removeGeofences(mGoogleApiClient, getGeofencePendingIntent()).setResultCallback(this); // Result processed in onResult().
LocationServices.GeofencingApi.addGeofences(mGoogleApiClient, getGeofencingRequest(), getGeofencePendingIntent()).setResultCallback(this); // Result processed in onResult().
} catch (SecurityException securityException) {
// Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
}
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
@Override
public void onResult(@NonNull Status status) {
}
private PendingIntent getGeofencePendingIntent() {
Intent intent = new Intent("ACTION_RECEIVE_GEOFENCE");
// We use FLAG_UPDATE_CURRENT so that we get the same pending intent back when calling addgeoFences()
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
private GeofencingRequest getGeofencingRequest() {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofence(geofence);
return builder.build();
}
}
私の活動では、私は同じことをしました。私はどのように私のジオフェンシングを再開するのですか?実行している地理フェンスを維持するために