In my android application, I am trying to get AccessToken from GoogleAuthUtil as below :
accessToken = GoogleAuthUtil.getToken(this, mPlusClient.getAccountName(), "oauth2:" + SCOPES);
But At this line I am gettting error as below :
E/GoogleAuthUtil(4696): Calling this from your main thread can lead to deadlock and/or ANRs E/GoogleAuthUtil(4696): java.lang.IllegalStateException: calling this from your main thread can lead to deadlock E/GoogleAuthUtil(4696): at com.google.android.gms.auth.GoogleAuthUtil.b(Unknown Source) E/GoogleAuthUtil(4696): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source) E/GoogleAuthUtil(4696): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
Any solution of this problem? Any help will be appreciated.
CrearEventoHilo.interrupt();
Sounds like you need to do that on a separate thread, have you tried that?
Here you can find information about threads in Android.
Use separate thread for your internet code. Error is telling that more time consuming process is running in the app and here that is internet. So use separate thread or Async task.
Check out this link NetworkOnMainThreadException
Hope it will help you.
Try it with an AsyncTask like this:
SCOPES
is a space separated list of OAuth 2.0 scope strings. For exampleSCOPES
could be defined as:These represent the permissions that your app is requesting from the user. The scopes requested in this example are documented here: