Kodeco Forums

Geofences on Android with GoogleApiClient

In this tutorial you'll learn how to leverage GoogleApiClient to add geofences to an Android app, as well as post notifications when a geofence is crossed.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1773-geofences-on-android-with-googleapiclient

Hello Ray,

Thanks a lot for such an awesome tutorial. I’m facing a problem where the app is getting force closed by saying goggleapliclient is not connected. Please find the details of the error as below.

java.lang.IllegalStateException: GoogleApiClient is not connected yet.
at com.google.android.gms.internal.zzme.zzb(Unknown Source)
at com.google.android.gms.internal.zzmi.zzb(Unknown Source)
at com.google.android.gms.internal.zzmg.zzb(Unknown Source)
at com.google.android.gms.location.internal.zzf.addGeofences(Unknown Source)
at com.purvotara.shanchaconsumer.network.geofence.GeofenceController$1.onConnected(GeofenceController.java:52)
at com.google.android.gms.common.internal.zzk.zzk(Unknown Source)
at com.google.android.gms.internal.zzmg.zzi(Unknown Source)
at com.google.android.gms.internal.zzme.zzpi(Unknown Source)
at com.google.android.gms.internal.zzme.onConnected(Unknown Source)
at com.google.android.gms.internal.zzmi.onConnected(Unknown Source)
at com.google.android.gms.internal.zzlz.onConnected(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzg.zzqv(Unknown Source)
at com.google.android.gms.common.internal.zzj$zza.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzj$zza.zzv(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzc.zzqx(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5236)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

Please let me know where it is going wrong…

Hello Ray,

I want to store and load the geofences in a sql database, but I don’t know how… :frowning:

Maybe you have a short advice for me, how I can solve this problem?

Thanks,
Mario

i am facing the same problem as mention by sharathnasa
java.lang.IllegalStateException: GoogleApiClient is not connected yet.
i come to know that two different instances of googleApiClient is created that what the issue is so there are possibly two solution either call GoogleApiClient in onCreate() method or make googleApiClient public static but none of them work for me can u provide me with a better solution thank you

Hello Ray, and Everyone!

Is there a way I can hard code the geofences in the app so that there are some available geofences for the users when they install the app? So that they don’t have to add the geofences for themselves(adding the geofences will be optional for them). Please help. I’ve trying to do it for the past two months following this tutorial but I can’t seem to get it right.

Thank You!

i am not able to see the notification and not able to know wheather the geofence is working or not…what should i do

This tutorial is more than six months old, so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]