Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use UiLifecycleHelper in any activity you want, just create a new one (it will automatically start using the active session). If you're using the active session, then it's a static that's preserved across all of your Activity instances, so you can access it from any activity simply by calling Session.getActiveSession(). As long as one of your activities have opened the session, you can use it in another activity.</p> <ol> <li><p>If your session is null, just create a new one and set it as the active session (or call one of the openActiveSession() methods). If the user has authorized your app already, it will go straight to the opened state** and you'll be able to use it. Same thing if it's closed. If the user hasn't authorized your app yet, both session.isOpened and session.isClosed will return false and you should probably redirect them to your login activity.</p></li> <li><p>I'm not quite sure how to answer this question. If you don't have an access token, then you'll need to open a session and get the publish permissions. Now way to really get around that.</p></li> <li><p>Yes, any time you open a session or request new permissions from an activity or fragment, you must override the onActivityResult, and pass through everything up to the session that you're acting against. The session will then call your StatusCallback that you registered with it (or the UiLifecycleHelper).</p></li> </ol> <p>** Note: it will only auto-open if it has cached data (which the SDK automatically saves). However, if you call session.closeAndClearTokenInformation, then the cache will be cleared, and it will prompt the user to authorize again.</p> <p>EDIT - to answer further questions:</p> <ol> <li><p>Yes, you can use that. If the user has logged in previously, the session will auto-populate using the cached data and go immediately into the OPENED state (as long as you haven't called closeAndClearTokenInformation in the past). All your permissions/access token are preserved. You can also use the <a href="https://developers.facebook.com/docs/reference/android/3.0/Session#openActiveSessionFromCache%28Context%29" rel="nofollow">Session.openActiveSessionFromCache</a> method, and if that returns null, that means we can't create an open session from cache (for any number of reasons), and you should prompt the user to re-login.</p></li> <li><p>By default, user access tokens last 60 days (I believe), and if you make your graph requests using the Request class provided by the SDK, it will auto-extend the tokens for you if they're expired. If the user changes their password or removes your app (or a number of other things), the access token will become invalid, and they MUST re-login and reauthorize your app. See <a href="https://developers.facebook.com/docs/reference/api/errors/" rel="nofollow">this page</a> on how to handle common errors.</p></li> <li><p>That looks fine. You'll want to make sure that the session you created is in the opened state first before calling requestNewPublishPermissions though. </p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload