public final class ParseFacebookUtils extends Object
ParseFacebookUtils
requires Facebook Android SDK v4.x.x
To use ParseFacebookUtils
, you'll need to set up the Facebook SDK:
Add the Facebook SDK: compile 'com.facebook.android:facebook-android-sdk:4.x.x'
Add the following to the <application>
node in your AndroidManifest.xml:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>Create
facebook_app_id
in your strings.xml with your Facebook App ID
Then you can use ParseFacebookUtils
:
Initialize ParseFacebookUtils
in your Application.onCreate()
:
public class MyApplication extends Application { public void onCreate() { Parse.initialize(this); ... ParseFacebookUtils.initialize(this); } }Add
onActivityResult(int, int, android.content.Intent)
to
your Activity.onActivityResult(int, int, android.content.Intent)
:
public class MyActivity extends Activity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); ParseFacebookUtils.onActivityResult(requestCode, resultCode, data); } }Lastly, log in with
logInWithReadPermissionsInBackground(android.app.Activity, java.util.Collection)
Modifier and Type | Method and Description |
---|---|
static void |
initialize(Context context)
Initializes
ParseFacebookUtils and com.facebook.FacebookSdk . |
static void |
initialize(Context context,
int callbackRequestCodeOffset)
Initializes
ParseFacebookUtils and com.facebook.FacebookSdk . |
static boolean |
isLinked(com.parse.ParseUser user) |
static Task<Void> |
linkInBackground(com.parse.ParseUser user,
AccessToken accessToken)
Link an existing Parse user with a Facebook account using authorization credentials that have
already been obtained.
|
static Task<Void> |
linkInBackground(com.parse.ParseUser user,
AccessToken accessToken,
com.parse.SaveCallback callback)
Link an existing Parse user with a Facebook account using authorization credentials that have
already been obtained.
|
static Task<Void> |
linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
Activity activity,
Collection<String> permissions)
Link an existing Parse user to Facebook with the requested publish permissions.
|
static Task<Void> |
linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
Activity activity,
Collection<String> permissions,
com.parse.SaveCallback callback)
Link an existing Parse user to Facebook with the requested publish permissions.
|
static Task<Void> |
linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
Fragment fragment,
Collection<String> permissions)
Link an existing Parse user to Facebook with the requested publish permissions.
|
static Task<Void> |
linkWithPublishPermissionsInBackground(com.parse.ParseUser user,
Fragment fragment,
Collection<String> permissions,
com.parse.SaveCallback callback)
Link an existing Parse user to Facebook with the requested publish permissions.
|
static Task<Void> |
linkWithReadPermissionsInBackground(com.parse.ParseUser user,
Activity activity,
Collection<String> permissions)
Link an existing Parse user to Facebook with the requested read permissions.
|
static Task<Void> |
linkWithReadPermissionsInBackground(com.parse.ParseUser user,
Activity activity,
Collection<String> permissions,
com.parse.SaveCallback callback)
Link an existing Parse user to Facebook with the requested read permissions.
|
static Task<Void> |
linkWithReadPermissionsInBackground(com.parse.ParseUser user,
Fragment fragment,
Collection<String> permissions)
Link an existing Parse user to Facebook with the requested read permissions.
|
static Task<Void> |
linkWithReadPermissionsInBackground(com.parse.ParseUser user,
Fragment fragment,
Collection<String> permissions,
com.parse.SaveCallback callback)
Link an existing Parse user to Facebook with the requested read permissions.
|
static Task<com.parse.ParseUser> |
logInInBackground(AccessToken accessToken)
Log in using a Facebook account using authorization credentials that have already been
obtained.
|
static Task<com.parse.ParseUser> |
logInInBackground(AccessToken accessToken,
com.parse.LogInCallback callback)
Log in using a Facebook account using authorization credentials that have already been
obtained.
|
static Task<com.parse.ParseUser> |
logInWithPublishPermissionsInBackground(Activity activity,
Collection<String> permissions)
Log in using Facebook login with the requested publish permissions.
|
static Task<com.parse.ParseUser> |
logInWithPublishPermissionsInBackground(Activity activity,
Collection<String> permissions,
com.parse.LogInCallback callback)
Log in using Facebook login with the requested publish permissions.
|
static Task<com.parse.ParseUser> |
logInWithPublishPermissionsInBackground(Fragment fragment,
Collection<String> permissions)
Log in using Facebook login with the requested publish permissions.
|
static Task<com.parse.ParseUser> |
logInWithPublishPermissionsInBackground(Fragment fragment,
Collection<String> permissions,
com.parse.LogInCallback callback)
Log in using Facebook login with the requested publish permissions.
|
static Task<com.parse.ParseUser> |
logInWithReadPermissionsInBackground(Activity activity,
Collection<String> permissions)
Log in using Facebook login with the requested read permissions.
|
static Task<com.parse.ParseUser> |
logInWithReadPermissionsInBackground(Activity activity,
Collection<String> permissions,
com.parse.LogInCallback callback)
Log in using Facebook login with the requested read permissions.
|
static Task<com.parse.ParseUser> |
logInWithReadPermissionsInBackground(Fragment fragment,
Collection<String> permissions)
Log in using Facebook login with the requested read permissions.
|
static Task<com.parse.ParseUser> |
logInWithReadPermissionsInBackground(Fragment fragment,
Collection<String> permissions,
com.parse.LogInCallback callback)
Log in using Facebook login with the requested read permissions.
|
static boolean |
onActivityResult(int requestCode,
int resultCode,
Intent data)
The method that should be called from the Activity's or Fragment's onActivityResult method.
|
static Task<Void> |
unlinkInBackground(com.parse.ParseUser user)
Unlink a user from a Facebook account.
|
static Task<Void> |
unlinkInBackground(com.parse.ParseUser user,
com.parse.SaveCallback callback)
Unlink a user from a Facebook account.
|
public static boolean isLinked(com.parse.ParseUser user)
true
if the user is linked to a Facebook account.public static void initialize(Context context)
ParseFacebookUtils
and com.facebook.FacebookSdk
.
This should be called in your Application.onCreate()
.context
- The application contextpublic static void initialize(Context context, int callbackRequestCodeOffset)
ParseFacebookUtils
and com.facebook.FacebookSdk
.
This should be called in your Application.onCreate()
.context
- The application contextcallbackRequestCodeOffset
- The request code offset that Facebook activities will be
called with. Please do not use the range between the
value you set and another 100 entries after it in your
other requests.public static boolean onActivityResult(int requestCode, int resultCode, Intent data)
requestCode
- The request code that's received by the Activity or Fragment.resultCode
- The result code that's received by the Activity or Fragment.data
- The result data that's received by the Activity or Fragment.true
if the result could be handled.public static Task<com.parse.ParseUser> logInInBackground(AccessToken accessToken)
accessToken
- Authorization credentials of a Facebook user.public static Task<com.parse.ParseUser> logInInBackground(AccessToken accessToken, com.parse.LogInCallback callback)
accessToken
- Authorization credentials of a Facebook user.callback
- A callback that will be executed when logging in is complete.public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Activity activity, Collection<String> permissions)
activity
- The activity which is starting the login process.permissions
- The requested permissions.public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Activity activity, Collection<String> permissions, com.parse.LogInCallback callback)
activity
- The activity which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when logging in is complete.public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Activity activity, Collection<String> permissions)
activity
- The activity which is starting the login process.permissions
- The requested permissions.public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Activity activity, Collection<String> permissions, com.parse.LogInCallback callback)
activity
- The activity which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when logging in is complete.public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Fragment fragment, Collection<String> permissions)
fragment
- The fragment which is starting the login process.permissions
- The requested permissions.public static Task<com.parse.ParseUser> logInWithReadPermissionsInBackground(Fragment fragment, Collection<String> permissions, com.parse.LogInCallback callback)
fragment
- The fragment which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when logging in is complete.public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Fragment fragment, Collection<String> permissions)
fragment
- The fragment which is starting the login process.permissions
- The requested permissions.public static Task<com.parse.ParseUser> logInWithPublishPermissionsInBackground(Fragment fragment, Collection<String> permissions, com.parse.LogInCallback callback)
fragment
- The fragment which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when logging in is complete.public static Task<Void> linkInBackground(com.parse.ParseUser user, AccessToken accessToken)
accessToken
- Authorization credentials of a Facebook user.public static Task<Void> linkInBackground(com.parse.ParseUser user, AccessToken accessToken, com.parse.SaveCallback callback)
accessToken
- Authorization credentials of a Facebook user.callback
- A callback that will be executed when linking is complete.public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions)
user
- The Parse user to link with.activity
- The activity which is starting the login process.permissions
- The requested permissions.public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions, com.parse.SaveCallback callback)
user
- The Parse user to link with.activity
- The activity which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when linking is complete.public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions)
user
- The Parse user to link with.activity
- The activity which is starting the login process.permissions
- The requested permissions.public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Activity activity, Collection<String> permissions, com.parse.SaveCallback callback)
user
- The Parse user to link with.activity
- The activity which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when linking is complete.public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions)
user
- The Parse user to link with.fragment
- The fragment which is starting the login process.permissions
- The requested permissions.public static Task<Void> linkWithReadPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions, com.parse.SaveCallback callback)
user
- The Parse user to link with.fragment
- The fragment which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when linking is complete.public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions)
user
- The Parse user to link with.fragment
- The fragment which is starting the login process.permissions
- The requested permissions.public static Task<Void> linkWithPublishPermissionsInBackground(com.parse.ParseUser user, Fragment fragment, Collection<String> permissions, com.parse.SaveCallback callback)
user
- The Parse user to link with.fragment
- The fragment which is starting the login process.permissions
- The requested permissions.callback
- A callback that will be executed when linking is complete.public static Task<Void> unlinkInBackground(com.parse.ParseUser user)
user
- The user to unlink.public static Task<Void> unlinkInBackground(com.parse.ParseUser user, com.parse.SaveCallback callback)
user
- The user to unlink.callback
- A callback that will be executed when unlinking is complete.