android - Ask for additional facebook permission -


i'm having trouble while trying retrieve additional permission "publish_action".

i assume user has logged in via facebook basic permissions granted. have code (from fragment):

list<string> permissionsrequested = arrays.aslist("publish_actions"); list<string> permissionsactual = session.getpermissions(); if (!issubsetof(permissionsrequested,  permissionsactual)) {     pendingpublishreauthorization = true;     session.newpermissionsrequest newpermissionsrequest = new session         .newpermissionsrequest(this, permissionsrequested);     session.requestnewpublishpermissions(newpermissionsrequest);     return; } 

seeing debug, after user grants permission, control goes onactivityresult, where, according facebook docs, have

super.onactivityresult(requestcode, resultcode, data); facebookuihelper.onactivityresult(requestcode, resultcode, data); 

uihelper (acording docs) used in onresume&ondestroy methods.

in oncreate have

super.oncreate(savedinstancestate); facebookuihelper = new uilifecyclehelper(getactivity(), fbsessioncallback); facebookuihelper.oncreate(savedinstancestate); 

where fbsessioncallback has overridden call() method, calls onfbsessionrestore():

if (pendingpublishreauthorization &&      state.equals(sessionstate.opened_token_updated)) {     pendingpublishreauthorization = false;     // things new session, updated granted permission. e.g. post fb. } 

trouble that

  1. onactivityresult executes, after no callback ever called, overridden call() won't go, , onfbsessioncallback either.
  2. if try post again (start things scratch) after - gets session without granted permission again, tries request , goes facebook exception pending newpublishrequest permission blah-blah

can configure workflow onactivityresult , later? read facebook docs , tend blame written badly. maybe it's me stupid... :(((

this how have set up:

session session = session.getactivesession();     if (session != null) {         list<string> permissions = session.getpermissions();         if (!permissions.contains("publish_actions")) {             session.newpermissionsrequest newpermissionsrequest = new session.newpermissionsrequest(this, "publish_actions");             session.addcallback(callbacktwo);             session.requestnewpublishpermissions(newpermissionsrequest);             return;         }     } 

this in onactivityresult doesn't need be. have used in oncreate before. added callback request can use next step.

here callback:

private session.statuscallback callbacktwo = new session.statuscallback() {      @override     public void call(session session, sessionstate state, exception exception) {         intent in = new intent(getactivity(), classhere.class);         startactivity(in);     } }; 

remember callback respond twice, once when start permission request, , after completed. have work around that/work code.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -