I am trying to find a location from the Service background. The problem is that the onResult() function inside Awareness.SnapshotApi.getLocation(mGoogleApiClient).setResultCallback(new ResultCallback<LocationResult>() NOT called. What could be wrong here?
The onConnected() and onConnectionSuspended() functions are also not called, but when I type mGoogleApiClient.isConnected() = true , it returns.
So, I am trying to understand why onConnected() does not call either.
public class BlockingService extends Service implements GoogleApiClient.ConnectionCallbacks { private GoogleApiClient mGoogleApiClient; @Override public int onStartCommand(Intent intent, int flags, int startId) { initAwarenessAPI(); amIClosetoLocation(<LatLng I get from my database>); return START_NOT_STICKY; } @Override public void onDestroy() { if (mGoogleApiClient.isConnected()) { mGoogleApiClient.disconnect(); } super.onDestroy(); } private void initAwarenessAPI() { Context context = getApplicationContext(); mGoogleApiClient = new GoogleApiClient.Builder(context) .addApi(Awareness.API) .build(); mGoogleApiClient.connect(); } private Boolean amIClosetoLocation(final LatLng savedLoc) { final String TAG = "Awareness"; mLog.printToLog(className + Constants.funcStart + MethodName.methodName() + ": Entered Function"); amIClosetoLocation = false; if (ContextCompat.checkSelfPermission( getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { mLog.printToLog(className + MethodName.methodName() + ": ***DONT HAVE LOCATION PERMISSION***"); } else { mLog.printToLog(className + MethodName.methodName() + ": Permission Exists -- so now going to get location"); Awareness.SnapshotApi.getLocation(mGoogleApiClient) .setResultCallback(new ResultCallback<LocationResult>() { @Override public void onResult(@NonNull LocationResult locationResult) {
source share