Android Facebook integration

I've got Facebook integration basically working in my app: the facebook dialog comes up and the user can select Allow or Don't Allow. However, I don't understand how the API works! I've got an Activity with this code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "in oncreate facebookactivity");
    facebook.authorize(this, new String[] {"publish_stream"}, new DialogListener() {

          public void onComplete(Bundle values) {
              Log.d(TAG, "facebook oncomplete with values " + values.toString());
          }

          public void onFacebookError(FacebookError error) {
            Log.e(TAG, "there was a FacebookError authorising: " + error);
          }

          public void onError(DialogError e) {
            Log.e(TAG, "there was a DialogError authorising: " + e);
          }

          public void onCancel() {
              Log.d(TAG, "facebook auth was cancelled");
          }

    });
    finish();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "facebook onactivityresult with resultcode " + resultCode);
    facebook.authorizeCallback(requestCode, resultCode, data);
    finish();
}

And NONE of my debug statements except the "in oncreate facebookactivity" ever prints.

My question is: how do I know whether the user has pressed Allow or Don't Allow? Is there something in the values sent to onComplete? Or something in the data sent to onActivityResult? The reason I need to know is because I would like to store the user's selection in the prefs of my app.

Many thanks

Nina

This question and answers originated from www.stackoverflow.com
Question by (3/21/2011 11:18:36 PM)

Answer

Only once you select Allow, FB begins to authorize your session, hence nothing happens until you select Allow. The DialogListener serves this purpose i.e. to capture what option the user selected. Because you haven't selected either choice your debug messages are not being logged.

The values parameter in the onComplete method contains your access token and your expiry time for that access token, once a user has selected Allow.

OnActivityResult is not related to this issue.

Answer by

Find More Answers
Related Topics  android  facebook
Related Questions
  • Android facebook integration

    I am developing an android application where I want to integrate facebook like. I was going through the link http://developers.facebook.com/docs/guides/mobile/#android I have few doubts: I g…
  • facebook integration on android

    the Fackbook or any of the other codes like updating status or etc all these things are working fine in android 2.1 but in 2.2 (on android device not emulator) it gives This page contains the fol…
  • Facebook integration in android application

    Is there any api for facebook to integration in android? I got a requirement to publish images to facebook through android application. Please give links or suggestions regarding this.. Tha…
  • Facebook integration in android

    Possible Duplicate: steps of integrating Facebook in android I want to integrate Facebook in my application where i want to share a link..can somebody tell me step by step how to integ…
  • Facebook integration in android

    Friends, I have an error in facebook integration on a button click it always returns NullPointerException,I don't know why? Please suggest me the right result...... Code: package com.ex.softZi…
  • Facebook Like button Integration in Android

    I want to integrate the Facebook Like button in my android application. Please tell me Steps how to integrate it in Android.
  • my facebook integration in android not working

    i had used the sample app for posting message on wall in android from site https://github.com/facebook/facebook-android-sdk . but what's happening is when my phone contains any other facebook app…
  • integration of facebook with application in android

    Now today I am working on Facebook integration with my application. I have successfully integrated Facebook with the application but I am in need of private data of the logged in user e.g. email add…
  • Facebook integration with android app without appId?

    hi i want to inegrate facebook to my android application but i do not have appId. so can it possible in android to call Facebook object without appId? when i try this it gives me error.in iphone it …
  • Android Facebook Integration - Predefined Wall Post

    I want to add functionality to my app where a user can share with their friends that they are using my app. I want the post to have a predefined message, but all I can get working is a regular post …