Geofences的问题 - addGeofence()没有'工作'?

时间:2018-05-01 13:45:19

标签: android android-geofence

我在创建Geofences列表时遇到问题。在我的onCreate方法中,我有一个for循环,它调用createGeofence()和createGeoFenceRequest()。在createGeofenceRequest中,构建器应使用addGeofence方法,然后调用createGeoFencePendingIntent()。我的堆栈跟踪显示在createGeofence()和createGeofenceRequest()被调用但没有别的。

我尝试创建的当前位置标记也未在地图上显示。

我正在按照本教程尝试添加自己的调整

https://code.tutsplus.com/tutorials/how-to-work-with-geofences-on-android--cms-26639

说实话,我很迷茫,我对android很新,而且我掌握的代码并不多。抱歉,如果我没有提供足够的信息,但如果需要更多信息,我会添加它。

这是我的代码:

LoggedInActivity

package com.mad.losesano2;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.Geofence;
import com.google.android.gms.location.GeofencingRequest;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import java.util.ArrayList;


public class LoggedInActivity extends AppCompatActivity
        implements
        GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener,
        OnMapReadyCallback,
        GoogleMap.OnMapClickListener,
        GoogleMap.OnMarkerClickListener,
        LocationListener, ResultCallback<Status> {

    private static GoogleApiClient googleApiClient;
    private Location lastLocation;
    private static final String TAG = MainActivity.class.getSimpleName();
    private LocationManager locationManager;
    private static final long MIN_TIME = 400;
    private static final float MIN_DISTANCE = 1000;

    private GoogleMap map;

    private ArrayList<Geofence> mGeofenceList = new ArrayList<>();
    ArrayList<Store> store_objects = new ArrayList<>();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logged_in);


        createGoogleApi();
        store_objects = (ArrayList<Store>) getIntent().getSerializableExtra("stores_objects");
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            for (Store store : store_objects) {


                Geofence geofence = createGeofence(store.getStoreID(), store.getLatitude(), store.getLongitude());
                mGeofenceList.add(geofence);
                createGeofenceRequest(geofence);


            }

        }

    private Geofence createGeofence( int id, double lat, double longi ) {
        Log.d(TAG, "createGeofence");
        return new Geofence.Builder()
                .setRequestId(Integer.toString(id))
                .setCircularRegion( lat, longi, 5)
                .setExpirationDuration(864000000)
                .setTransitionTypes( Geofence.GEOFENCE_TRANSITION_ENTER )
                .build();
    }

    private GeofencingRequest createGeofenceRequest( Geofence geofence ) {
        Log.d(TAG, "createGeofenceRequest");
        return new GeofencingRequest.Builder()
                .setInitialTrigger( GeofencingRequest.INITIAL_TRIGGER_ENTER )
                .addGeofence( geofence )
                .build();
    }

    private void createGoogleApi() {
        Log.d(TAG, "createGoogleApi()");
        if ( googleApiClient == null ) {
            googleApiClient = new GoogleApiClient.Builder( this )
                    .addConnectionCallbacks( this )
                    .addOnConnectionFailedListener( this )
                    .addApi( LocationServices.API )
                    .build();
        }
    }

    private PendingIntent geoFencePendingIntent;
    private final int GEOFENCE_REQ_CODE = 0;

    private PendingIntent createGeofencePendingIntent() {
        Log.d(TAG, "createGeofencePendingIntent");
        if ( geoFencePendingIntent != null )
            return geoFencePendingIntent;

        Intent intent = new Intent( this, GeofenceTransitionService.class);
        return PendingIntent.getService(
                this, GEOFENCE_REQ_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT );
    }

    private void addGeofence(GeofencingRequest request) {
        Log.d(TAG, "addGeofence");
        if (checkPermission())
            LocationServices.GeofencingApi.addGeofences(
                    googleApiClient,
                    request,
                    createGeofencePendingIntent()
            ).setResultCallback(this);
    }

    protected void onStart() {
        super.onStart();
        googleApiClient.connect();
    }

    @Override
    public void onConnected(@Nullable Bundle bundle) {
        Log.i(TAG, "onConnected()");
        getLastKnownLocation();
    }
    @Override
    public void onConnectionSuspended(int i) {

    }
    @Override
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

    }
    @Override
    public void onMapClick(LatLng latLng) {
        Log.d(TAG, "onMapClick("+latLng +")");
        markerForGeofence(latLng);
    }


    private Marker locationMarker;
    private void markerLocation(LatLng latLng) {
        Log.i(TAG, "markerLocation("+latLng+")");
        String title = latLng.latitude + ", " + latLng.longitude;
        MarkerOptions markerOptions = new MarkerOptions()
                .position(latLng)
                .title(title);
        if ( map!=null ) {
            // Remove the anterior marker
            if ( locationMarker != null )
                locationMarker.remove();
            locationMarker = map.addMarker(markerOptions);
            float zoom = 14f;
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, zoom);
            map.animateCamera(cameraUpdate);
        }
    }

    private Marker geoFenceMarker;
    // Create a marker for the geofence creation
    private void markerForGeofence(LatLng latLng) {
        Log.i(TAG, "markerForGeofence("+latLng+")");
        String title = latLng.latitude + ", " + latLng.longitude;
        // Define marker options
        MarkerOptions markerOptions = new MarkerOptions()
                .position(latLng)
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE))
                .title(title);
        if ( map!=null ) {
            // Remove last geoFenceMarker
            if (geoFenceMarker != null)
                geoFenceMarker.remove();

            geoFenceMarker = map.addMarker(markerOptions);
        }
    }
    public boolean onMarkerClick(Marker marker) {
        return false;
    }
    @Override
    public void onMapReady(GoogleMap googleMap) {

    }
    @Override
    public void onLocationChanged(Location location) {
        Log.d(TAG, "onLocationChanged ["+location+"]");
        lastLocation = location;
        writeActualLocation(location);
    }
    private void getLastKnownLocation() {
        Log.d(TAG, "getLastKnownLocation()");
        if ( checkPermission() ) {
            lastLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
            if ( lastLocation != null ) {
                Log.i(TAG, "LasKnown location. " +
                        "Long: " + lastLocation.getLongitude() +
                        " | Lat: " + lastLocation.getLatitude());
                writeLastLocation();
                startLocationUpdates();
            } else {
                Log.w(TAG, "No location retrieved yet");
                startLocationUpdates();
            }
        }
        else {
            Log.d("LoSeSANO", "Permissions needed");
        }
    }
    private LocationRequest locationRequest;
    private final int UPDATE_INTERVAL =  1000;
    private final int FASTEST_INTERVAL = 900;
    private void startLocationUpdates(){
        Log.i(TAG, "startLocationUpdates()");
        locationRequest = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setInterval(UPDATE_INTERVAL)
                .setFastestInterval(FASTEST_INTERVAL);

        if ( checkPermission() )
            LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    }
    private void writeActualLocation(Location location) {
        markerLocation(new LatLng(location.getLatitude(), location.getLongitude()));
    }
    private void writeLastLocation() {
        writeActualLocation(lastLocation);
    }
    private boolean checkPermission() {
        Log.d(TAG, "checkPermission()");
        // Ask for permission if it wasn't granted yet
        return (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
                == PackageManager.PERMISSION_GRANTED );
    }
    @Override
    public void onResult(@NonNull Status status) {
        Log.i(TAG, "onResult: " + status);
        if ( status.isSuccess() ) {
            drawGeofence();
        }
    }

    private Circle geoFenceLimits;
    private void drawGeofence() {
        Log.d(TAG, "drawGeofence()");

        if ( geoFenceLimits != null )
            geoFenceLimits.remove();

        CircleOptions circleOptions = new CircleOptions()
                .center( geoFenceMarker.getPosition())
                .strokeColor(Color.argb(50, 70,70,70))
                .fillColor( Color.argb(100, 150,150,150) )
                .radius( 5 );
        geoFenceLimits = map.addCircle( circleOptions );
    }

    static Intent makeNotificationIntent(Context geofenceService, String msg)
    {
        Log.d(TAG,msg);
        return new Intent(geofenceService,MainActivity.class);
    }


}

GeofenceTransitionService

    package com.mad.losesano2;


        import android.app.IntentService;
        import android.app.Notification;
        import android.app.NotificationManager;
        import android.app.PendingIntent;
        import android.app.TaskStackBuilder;
        import android.content.Context;
        import android.content.Intent;
        import android.graphics.Color;
        import android.support.v4.app.NotificationCompat;
        import android.text.TextUtils;
        import android.util.Log;

        import com.google.android.gms.location.Geofence;
        import com.google.android.gms.location.GeofenceStatusCodes;
        import com.google.android.gms.location.GeofencingEvent;

        import java.util.ArrayList;
        import java.util.List;

public class GeofenceTransitionService extends IntentService {

    private static final String TAG = GeofenceTransitionService.class.getSimpleName();

    public static final int GEOFENCE_NOTIFICATION_ID = 0;

    public GeofenceTransitionService() {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
        if ( geofencingEvent.hasError() ) {
            String errorMsg = getErrorString(geofencingEvent.getErrorCode() );
            Log.e( TAG, errorMsg );
            return;
        }

        int geoFenceTransition = geofencingEvent.getGeofenceTransition();
        if ( geoFenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER ||
                geoFenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT ) {
            List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();

            String geofenceTransitionDetails = getGeofenceTransitionDetails(geoFenceTransition, triggeringGeofences );

            sendNotification( geofenceTransitionDetails );
        }
    }


    private String getGeofenceTransitionDetails(int geoFenceTransition, List<Geofence> triggeringGeofences) {
        ArrayList<String> triggeringGeofencesList = new ArrayList<>();
        for ( Geofence geofence : triggeringGeofences ) {
            triggeringGeofencesList.add( geofence.getRequestId() );
        }

        String status = null;
        if ( geoFenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER )
            status = "Entering ";
        else if ( geoFenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT )
            status = "Exiting ";
        return status + TextUtils.join( ", ", triggeringGeofencesList);
    }

    private void sendNotification( String msg ) {
        Log.i(TAG, "sendNotification: " + msg );

        // Intent to start the main Activity
        Intent notificationIntent = LoggedInActivity.makeNotificationIntent(
                getApplicationContext(), msg
        );

        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(MainActivity.class);
        stackBuilder.addNextIntent(notificationIntent);
        PendingIntent notificationPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);


        // Creating and sending Notification
        NotificationManager notificatioMng =
                (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE );
        notificatioMng.notify(
                GEOFENCE_NOTIFICATION_ID,
                createNotification(msg, notificationPendingIntent));

    }

    // Create notification
    private Notification createNotification(String msg, PendingIntent notificationPendingIntent) {
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
        notificationBuilder
                .setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
                .setColor(Color.RED)
                .setContentTitle(msg)
                .setContentText("Geofence Notification!")
                .setContentIntent(notificationPendingIntent)
                .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND)
                .setAutoCancel(true);
        return notificationBuilder.build();
    }


    private static String getErrorString(int errorCode) {
        switch (errorCode) {
            case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
                return "GeoFence not available";
            case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
                return "Too many GeoFences";
            case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
                return "Too many pending intents";
            default:
                return "Unknown error.";
        }
    }
}

堆栈跟踪

05-01 13:41:18.948 7820-7820/com.mad.losesano2 V/FA: onActivityCreated
05-01 13:41:18.949 7820-7911/com.mad.losesano2 D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=12726, firebase_screen_class(_sc)=SignupActivity, firebase_screen_id(_si)=-6720222596079632252}]
05-01 13:41:18.998 7820-7911/com.mad.losesano2 V/FA: Connection attempt already in progress
05-01 13:41:19.006 7820-7911/com.mad.losesano2 V/FA: Connection attempt already in progress
05-01 13:41:19.006 7820-7911/com.mad.losesano2 V/FA: Activity resumed, time: 42701370
05-01 13:41:19.019 7820-7911/com.mad.losesano2 D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=SignupActivity, firebase_previous_id(_pi)=-6720222596079632252, firebase_screen_class(_sc)=StoreListRegisterActivity, firebase_screen_id(_si)=-6720222596079632251}]
05-01 13:41:19.062 7820-7911/com.mad.losesano2 V/FA: Connection attempt already in progress
05-01 13:41:19.293 7820-7911/com.mad.losesano2 D/FA: Connected to remote service
05-01 13:41:19.293 7820-7911/com.mad.losesano2 V/FA: Processing queued up service tasks: 4
05-01 13:41:19.304 7820-7848/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa7b05720: ver 3 0 (tinfo 0xa7b03370)
05-01 13:41:22.146 7820-7911/com.mad.losesano2 V/FA: Recording user engagement, ms: 3139
05-01 13:41:22.148 7820-7911/com.mad.losesano2 V/FA: Activity paused, time: 42704509
05-01 13:41:22.151 7820-7911/com.mad.losesano2 D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=3139, firebase_screen_class(_sc)=StoreListRegisterActivity, firebase_screen_id(_si)=-6720222596079632251}]
05-01 13:41:22.159 7820-7820/com.mad.losesano2 V/FA: onActivityCreated
05-01 13:41:22.202 7820-7820/com.mad.losesano2 I/zzbz: Making Creator dynamically
05-01 13:41:22.211 7820-7820/com.mad.losesano2 I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:219
05-01 13:41:22.212 7820-7820/com.mad.losesano2 I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 219
05-01 13:41:22.262 7820-7820/com.mad.losesano2 W/zygote: Skipping duplicate class check due to unrecognized classloader
05-01 13:41:22.297 7820-7820/com.mad.losesano2 I/Google Maps Android API: Google Play services client version: 11910000
05-01 13:41:22.302 7820-7820/com.mad.losesano2 I/Google Maps Android API: Google Play services package version: 12529024
05-01 13:41:22.580 7820-7991/com.mad.losesano2 D/NetworkSecurityConfig: No Network Security Config specified, using platform default
05-01 13:41:22.614 7820-7820/com.mad.losesano2 D/MainActivity: createGoogleApi()
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofence
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofenceRequest
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofence
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofenceRequest
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofence
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofenceRequest
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofence
05-01 13:41:22.618 7820-7820/com.mad.losesano2 D/MainActivity: createGeofenceRequest
05-01 13:41:22.631 7820-7826/com.mad.losesano2 I/zygote: Do full code cache collection, code=450KB, data=345KB
05-01 13:41:22.632 7820-7911/com.mad.losesano2 V/FA: Activity resumed, time: 42704996
05-01 13:41:22.633 7820-7826/com.mad.losesano2 I/zygote: After code cache collection, code=449KB, data=291KB
05-01 13:41:22.636 7820-7911/com.mad.losesano2 D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=StoreListRegisterActivity, firebase_previous_id(_pi)=-6720222596079632251, firebase_screen_class(_sc)=LoggedInActivity, firebase_screen_id(_si)=-6720222596079632250}]
05-01 13:41:22.726 7820-7848/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa7b05720: ver 3 0 (tinfo 0xa7b03370)
05-01 13:41:22.731 7820-8014/com.mad.losesano2 D/EGL_emulation: eglCreateContext: 0xa4efc540: maj 1 min 0 rcv 1
05-01 13:41:22.766 7820-8014/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa4efc540: ver 1 0 (tinfo 0xa4f2a700)
05-01 13:41:22.789 7820-7848/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa7b05720: ver 3 0 (tinfo 0xa7b03370)
05-01 13:41:22.832 7820-7848/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa7b05720: ver 3 0 (tinfo 0xa7b03370)
05-01 13:41:22.860 7820-7848/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa7b05720: ver 3 0 (tinfo 0xa7b03370)
05-01 13:41:22.866 7820-7820/com.mad.losesano2 I/MainActivity: onConnected()
05-01 13:41:22.867 7820-7820/com.mad.losesano2 D/MainActivity: getLastKnownLocation()
05-01 13:41:22.867 7820-7820/com.mad.losesano2 D/MainActivity: checkPermission()
05-01 13:41:22.878 7820-7820/com.mad.losesano2 I/MainActivity: LasKnown location. Long: 6.3433983 | Lat: 5.432
05-01 13:41:22.878 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:41:22.878 7820-7820/com.mad.losesano2 I/MainActivity: startLocationUpdates()
05-01 13:41:22.879 7820-7820/com.mad.losesano2 D/MainActivity: checkPermission()
05-01 13:41:22.931 7820-7848/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa7b05720: ver 3 0 (tinfo 0xa7b03370)
05-01 13:41:22.948 7820-7848/com.mad.losesano2 D/OpenGLRenderer: endAllActiveAnimators on 0x94336080 (RippleDrawable) with handle 0xa7b03f00
05-01 13:41:22.959 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=20 et=+11h51m45s283ms alt=0.0 vAcc=40 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:41:22.959 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:41:22.975 7820-7848/com.mad.losesano2 D/EGL_emulation: eglMakeCurrent: 0xa7b05720: ver 3 0 (tinfo 0xa7b03370)
05-01 13:41:23.292 7820-7826/com.mad.losesano2 I/zygote: Do partial code cache collection, code=495KB, data=330KB
05-01 13:41:23.293 7820-7826/com.mad.losesano2 I/zygote: After code cache collection, code=485KB, data=324KB
05-01 13:41:23.293 7820-7826/com.mad.losesano2 I/zygote: Increasing code cache capacity to 2MB
05-01 13:41:24.621 7820-8016/com.mad.losesano2 W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
05-01 13:41:24.627 7820-8016/com.mad.losesano2 I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
05-01 13:41:24.627 7820-8016/com.mad.losesano2 I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 4
05-01 13:41:24.632 7820-8016/com.mad.losesano2 W/zygote: Skipping duplicate class check due to unrecognized classloader
05-01 13:41:27.689 7820-7911/com.mad.losesano2 V/FA: Inactivity, disconnecting from the service
05-01 13:41:31.442 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h51m53s799ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:41:31.442 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:41:41.438 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h52m3s799ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:41:41.438 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:41:51.437 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h52m13s799ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:41:51.437 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:42:01.438 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h52m23s799ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:42:01.438 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:42:11.437 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h52m33s799ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:42:11.437 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:42:21.444 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h52m43s800ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:42:21.444 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:42:31.439 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h52m53s801ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:42:31.440 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:42:41.439 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h53m3s800ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:42:41.439 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:42:51.445 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h53m13s803ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:42:51.446 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:43:01.439 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h53m23s801ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:43:01.439 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))
05-01 13:43:11.440 7820-7820/com.mad.losesano2 D/MainActivity: onLocationChanged [Location[fused 5.432000,6.343398 hAcc=23 et=+11h53m33s802ms alt=0.0 vAcc=47 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}]]
05-01 13:43:11.441 7820-7820/com.mad.losesano2 I/MainActivity: markerLocation(lat/lng: (5.432,6.3433983))

1 个答案:

答案 0 :(得分:0)

根本没有调用{p> createGeoFencePendingIntent。此外,您说“在createGeofenceRequest内,构建器应使用addGeofence方法”,但addGeofence方法不是您定义的方法,而是构建器方法。