private void doShare( Context context, String link, String thumb, String name, String description) { Bundle params = new Bundle(); params.putString("link", link); params.putString("picture", thumb); params.putString("name", name); params.putString("description", description); facebook.dialog( context, "feed", params, new DialogListener() { @Override public void onFacebookError(FacebookError arg0) {} @Override public void onError(DialogError arg0) {} @Override public void onComplete(Bundle arg0) {} @Override public void onCancel() {} }); context = null; // release for gc }
private void postToFacebook(String comment) { Bundle extras = new Bundle(); extras.putString("link", currentEvent.getUri()); extras.putString("name", currentEvent.getName()); facebook.dialog( this, "feed", extras, new Facebook.DialogListener() { public void onFacebookError(FacebookError e) { // TODO Auto-generated method stub } public void onError(DialogError e) { // TODO Auto-generated method stub } public void onComplete(Bundle values) { // TODO Auto-generated method stub } public void onCancel() { // TODO Auto-generated method stub } }); }
/** * Internal method to handle dialog-based authentication backend for authorize(). * * @param activity The Android Activity that will parent the auth dialog. * @param applicationId The Facebook application identifier. * @param permissions A list of permissions required for this application. If you do not require * any permissions, pass an empty String array. */ private void startDialogAuth(Activity activity, String[] permissions) { Bundle params = new Bundle(); if (permissions.length > 0) { params.putString("scope", TextUtils.join(",", permissions)); } CookieSyncManager.createInstance(activity); dialog( activity, LOGIN, params, new DialogListener() { public void onComplete(Bundle values) { // ensure any cookies set by the dialog are saved CookieSyncManager.getInstance().sync(); setAccessToken(values.getString(TOKEN)); setAccessExpiresIn(values.getString(EXPIRES)); if (isSessionValid()) { Log.d( "Facebook-authorize", "Login Success! access_token=" + getAccessToken() + " expires=" + getAccessExpires()); mAuthDialogListener.onComplete(values); } else { mAuthDialogListener.onFacebookError( new FacebookError("Failed to receive access token.")); } } public void onError(DialogError error) { Log.d("Facebook-authorize", "Login failed: " + error); mAuthDialogListener.onError(error); } public void onFacebookError(FacebookError error) { Log.d("Facebook-authorize", "Login failed: " + error); mAuthDialogListener.onFacebookError(error); } public void onCancel() { Log.d("Facebook-authorize", "Login canceled"); mAuthDialogListener.onCancel(); } }); }
// POST ON USERS WALL public void postToWall() { // post on user's wall. facebook.dialog( this, "feed", new DialogListener() { @Override public void onFacebookError(FacebookError e) {} @Override public void onError(DialogError e) {} @Override public void onComplete(Bundle values) {} @Override public void onCancel() {} }); }
/** * Generate a UI dialog for the request action in the given Android context. * * <p>Note that this method is asynchronous and the callback will be invoked in the original * calling thread (not in a background thread). * * @param context The Android context in which we will generate this dialog. * @param action String representation of the desired method: e.g. "login", "stream.publish", ... * @param listener Callback interface to notify the application when the dialog has completed. */ public void dialog(Context context, String action, DialogListener listener) { dialog(context, action, new Bundle(), listener); }