geofence 이용해서 위치기반 서비스 개발하고 있는데요
맨 처음에 실행할때는 문제없이 잘 작동하는데 2~3번 실행하면 해당 오류가 발생합니다
java.lang.IllegalArgumentException: No geofence has been added to this request
at com.geofencing.jeon.geofencingtest.geofence.MyGeofence.getGeofencingRequest(MyGeofence.java:16)
at com.geofencing.jeon.geofencingtest.MainActivity.onConnected(MainActivity.java:212)
onCreate() 에서 connect()함수를 호출합니다
public static final GeofencingRequest getGeofencingRequest(List<Geofence> mGeofenceList) {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER | GeofencingRequest.INITIAL_TRIGGER_EXIT);
builder.addGeofences(mGeofenceList);
return builder.build();
}
@Override
public void onConnected(Bundle bundle) {
mGeofenceRequestIntent = getGeofenceTransitionPendingIntent();
LocationServices.GeofencingApi.addGeofences(mApiClient, MyGeofence.getGeofencingRequest(mGeofenceList),
mGeofenceRequestIntent);
Toast.makeText(this, getString(R.string.start_geofence_service), Toast.LENGTH_SHORT).show();
//finish();
}