So, I found something that I don’t really understand about GoogleApiClient. GoogleApiClient has an onConnected function that runs when the client is connected (for sure)
I got my own function: startLocationListening , which ultimately gets a call to the GoogleApiClient onConnected function .
So my startLocationListening function could not work without a GoogleApiClient connection.
Code and log:
@Override public void onConnected(Bundle bundle) { log("Google_Api_Client:connected."); initLocationRequest(); startLocationListening();
...
private void startLocationListening() { log("Starting_location_listening:now");
The exception is:
03-30 12:23:28.947: E/AndroidRuntime(4936): java.lang.IllegalStateException: GoogleApiClient is not connected yet. 03-30 12:23:28.947: E/AndroidRuntime(4936): at com.google.android.gms.internal.jx.a(Unknown Source) 03-30 12:23:28.947: E/AndroidRuntime(4936): at com.google.android.gms.common.api.cb(Unknown Source) 03-30 12:23:28.947: E/AndroidRuntime(4936): at com.google.android.gms.internal.nf.requestLocationUpdates(Unknown Source) 03-30 12:23:28.947: E/AndroidRuntime(4936): at hu.company.testproject.service.GpsService.startLocationListening(GpsService.java:169) 03-30 12:23:28.947: E/AndroidRuntime(4936): at hu.company.testproject.service.GpsService.onConnected(GpsService.java:259)
...
My debug log also says that the onConnected function received a call :
03-30 12:23:28.847: I/Locationing_GpsService(4936): Google_Api_Client:connected. 03-30 12:23:28.857: I/Locationing_GpsService(4936): initLocationRequest:initing_now 03-30 12:23:28.877: I/Locationing_GpsService(4936): initLocationRequest:interval_5000 03-30 12:23:28.897: I/Locationing_GpsService(4936): initLocationRequest:priority_100 03-30 12:23:28.917: I/Locationing_GpsService(4936): Starting_location_listening:now
After that I got an exception.
Am I missing something? I got a response for “connected,” I ran my func, and I got a “not connected” error, what is it? Plus one annoying thing: I used this location service for several weeks and never got this error.
ED i T:
I added a more specific log output, just blew my mind, check this out:
@Override public void onConnected(Bundle bundle) { if(mGoogleApiClient.isConnected()){ log("Google_Api_Client: It was connected on (onConnected) function, working as it should."); } else{ log("Google_Api_Client: It was NOT connected on (onConnected) function, It is definetly bugged."); } initLocationRequest(); startLocationListening(); }
log output in this case:
03-30 16:20:00.950: I/Locationing_GpsService(16608): Google_Api_Client:connected. 03-30 16:20:00.960: I/Locationing_GpsService(16608): Google_Api_Client: It was NOT connected on (onConnected) function, It is definetly bugged.
Yes, I just got mGoogleApiClient.isConnected() == false inside onConnected() , how is this possible?
ED i T:
Since no one could answer this even with gratitude for the reputation , I decided to report it as a bug for Google. What happened next really surprised me. The official Google response to my report:
“This website is intended for developers using the AOSP source for Android code and a set of developer tools, and not Google applications or services such as Play Services, GMS or Google APIs. Unfortunately, this seems to be a good place to report errors in Play Services. All I can say is that this site is wrong, sorry. Try posting on the Google Product Forum. "
Full release report here. (I hope they don’t remove it just because its stupid)
So, I looked at the Google Product Forums and just found some topic to post this stuff, so at the moment the pit is puzzled and stuck.
Can anyone on planet earth help me with this?
ED i T:
Full code in pastebin