I get this in log always.***Activity is launching as a new task, so cancelling activity result***. What does this mean? I searched in this forum about this and found that this has something to do with * android:launchMode="singleInstance"*. But when I removed this, I got some other errors like Authentication failed because of invalid android app key. What do I do? I'm so confused and exhausted
On Thursday, April 12, 2012 11:34:40 AM UTC+5:30, Kamal Kambe wrote: > > I'm trying to integrate facebook into an android application. I have added > the code the facebook authorization (followed all the steps as per > guidelines from here > http://developers.facebook.com/docs/mobile/android/build/). Whenever the > facebook authorization happens, onActivityResult will be called back but > with data as null and resultCode as 0 (zero/RESULT_CANCELED). > > Here's my code: > > Main Activity class > > @Override > public void onActivityResult(int requestCode, int resultCode, Intent data) { > > super.onActivityResult(requestCode, resultCode, data); > MCAndroidFBIntegration.authorizeCallback(requestCode, resultCode, data); > } > > MCAndroidFBIntegration.java > > public class MCAndroidFBIntegration implements IFacebookIntegration { > > private static final String APP_ID = APP_ID_NUMBER; > private static Facebook facebook; > private AsyncFacebookRunner mAsyncFBRunner; > public Preferences mPrefs; > private Context ctx; > private static MCAndroidFBIntegration mcAndroidFBIntegration; > > public MCAndroidFBIntegration(Context ctx) { > this.ctx = ctx; > } > > @Override > public void integrate() { > // Integrate with Facebook > facebook = new Facebook(APP_ID); > mAsyncFBRunner = new AsyncFacebookRunner(facebook); > loginToFacebook(); > } > > private void loginToFacebook() { > mPrefs = GamePreference.getPreferences(); > String accessToken = mPrefs.getString(Config.ACCESS_TOKEN, null); > long expires = mPrefs.getLong(Config.ACCESS_EXPIRES, 0); > > if (accessToken != null) { > facebook.setAccessToken(accessToken); > } > > if (expires != 0) { > facebook.setAccessExpires(expires); > } > > if (!facebook.isSessionValid()) { > facebook.authorize((Activity) ctx, new String[] { "publish_stream", > "read_stream", "offline_access"}, new DialogListener() { > > @Override > public void onCancel() { > // Function to handle cancel event > System.out.println("Facebook:: event cancelled"); > } > > @Override > public void onComplete(Bundle values) { > // Function to handle complete event > // Edit Preferences and update facebook acess_token > System.out > .println("Facebook:: setting access token and expire > time in preferences"); > User user = User.getUser(); > if (user != null) { > user.setAccessToken(facebook.getAccessToken()); > user.setAccessExpires(facebook.getAccessExpires()); > user.updatePrefs(); > mPrefs.flush(); > } > } > > @Override > public void onError(DialogError error) { > // Function to handle error > System.out.println("Facebook:: Error - " > + error.getLocalizedMessage()); > > } > > @Override > public void onFacebookError(FacebookError fberror) { > // Function to handle Facebook errors > System.out.println("Facebook:: fbError - code: " > + fberror.getErrorCode() + " message: " > + fberror.getLocalizedMessage()); > } > > }); > } > } > > public static void authorizeCallback(int requestCode, int resultCode, > Intent data) { > if (data != null) { > String error = data.getStringExtra("error"); > if (error != null) { > String description = data.getStringExtra("error_description"); > System.out.println("Facebook:: error desc - " + description); > } else { > String token = data.getStringExtra("access_token"); > String expires = data.getStringExtra("expires_in"); > System.out.println("Facebook:: call back access token - " > + token); > System.out.println("Facebook:: call back expires - " + expires); > } > } > facebook.authorizeCallback(requestCode, resultCode, data); > } > > > Cam someone please tell me what is the mistake that I'm doing here. > > > Thanks, > > Kamal > > > > > > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

