android - onActivityResult not called on facebook sign in -


i have android app facebook sign in.i initialized facebook sdk in fragment.but onactivityresult never called when launching sign in procedure.

@override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {         // inflate layout fragment         facebooksdk.sdkinitialize(getcontext());         appeventslogger.activateapp(getcontext());         facebooksdk.setapplicationid(getresources().getstring(r.string.facebook_app_id));         callbackmanager = callbackmanager.factory.create();         view view=inflater.inflate(r.layout.fragment_signin, container, false);         gbutton=(button)view.findviewbyid(r.id.logingmail);         fbutton=(loginbutton) view.findviewbyid(r.id.loginfacebook);         googlesigninoptions gso = new googlesigninoptions.builder(googlesigninoptions.default_sign_in)                 .requestemail()                 .build();         fbutton.setreadpermissions("email");         gbutton.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 signin();             }         });         mgoogleapiclient = new googleapiclient.builder(getcontext())                 .enableautomanage(getactivity() /* fragmentactivity */, /* onconnectionfailedlistener */)                 .addapi(auth.google_sign_in_api, gso)                 .build();         fbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() {             @override             public void onsuccess(loginresult loginresult) {                 toast.maketext(getactivity(),"success"+loginresult.getaccesstoken(),toast.length_long).show();              }              @override             public void oncancel() {              }              @override             public void onerror(facebookexception error) {                 toast.maketext(getactivity(),"failed",toast.length_long).show();              }         });          return view;     }     @override     public void onactivityresult(int requestcode, int resultcode, intent data) {         super.onactivityresult(requestcode, resultcode, data);         callbackmanager.onactivityresult(requestcode,resultcode, data);         // result returned launching intent googlesigninapi.getsigninintent(...);         if (requestcode == rc_sign_in) {             googlesigninresult result = auth.googlesigninapi.getsigninresultfromintent(data);             handlesigninresult(result);         }     }     private void signin() {         intent signinintent = auth.googlesigninapi.getsigninintent(mgoogleapiclient);         startactivityforresult(signinintent, rc_sign_in);     } 

but onactivityresult called when google sign in initiated.

finally got answer. forgot add

fbutton.setfragment(this); 

for fragments setfragment(this); method required. refer this.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -