Android signin with Google plus issue on the first login -


i implemented signin google no problems. using fragment in place of activity. testing code on samsung galaxies happens signin system goes idle , not call onconnected method. happens first time, when terms , conditions shows. advice? here code:

@override public void onactivitycreated(bundle savedinstancestate) {    super.onactivitycreated(savedinstancestate);    initgoogle() }   private void initgoogle() {     mplusclient = new plusclient.builder(getactivity() , , this).setvisibleactivities("http://schemas.google.com/addactivity", "http://schemas.google.com/buyactivity").build();  }  public void connectwithplus() {     launchprogressscreen();     if(mplusclient != null && !mplusclient.isconnected()){          mplusclient.connect();     }else{          mplusclient.cleardefaultaccount();         mplusclient.disconnect();         mplusclient.connect();     } }  @override public void onactivityresult(int requestcode, int resultcode, intent data) {     if (requestcode == request_code_resolve_err) {     mconnectionresult = null;     connectwithplus();   } } @override public void onconnectionfailed(connectionresult result) {     if (result!= null && result.hasresolution()) {         try {             result.startresolutionforresult(getactivity(), request_code_resolve_err);         } catch (sendintentexception e) {             connectwithplus();         }         mconnectionresult = result;     }else{         ontaskresult(progressalert.task_cancel_google_login, null);     } } @override public void onconnected(bundle connectionhint) {     asynctask<object, void, string> task = new asynctask<object, void, string>()    {         @override         protected string doinbackground(object... params) {             string token = null;             try {                 token = googleauthutil.gettoken(getactivity(), mplusclient.getaccountname(),                             "oauth2:" + scopes.plus_login );             } catch (userrecoverableauthexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (googleauthexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }             return token;         }          @override         protected void onpostexecute(string token){             getauthdelegate().settoken(token, socialaccount.google);             getauthdelegate().loginusinggoogle(token, new hashmap<string, string>());         }     };     task.execute(); }  @override public void ondisconnected() {     log.w("google login", "called disconnected"); }  @override public void onclick(view v) {     connectwithplus(); } 

i faced same problem , fixed overriding onresume method in fragment.

@override     public void onresume() {         // todo auto-generated method stub         super.onresume();         mgoogleapiclient.connect();     } 

i still not sure if valid solution or not.

thanks, rahul


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -