Following is the code that I did to create a facebook event, however this code does not work, no compile or run time errors. I have written the method and called the method on button click event.
public class createEvent extends Activity implements OnClickListener
{
private Button btnCreateEven;
private TextView txteventName;
private AsyncFacebookRunner mAsyncRunner;
private String eventID="";
private Facebook facebookatEventCreate;
private String eventName = "";
private SharedPreferences mPrefs;
private static String appId = "392736034134808";
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.create_event);
//problem - unable to start activity when setListeners() is uncommented
initialize();
setListeners();
}
private void initialize()
{
//facebook = new Facebook(APP_ID);
facebookatEventCreate = new Facebook(appId);
mAsyncRunner = new AsyncFacebookRunner(facebookatEventCreate);
btnCreateEven = (Button) findViewById(R.id.btn_createEvent);
txteventName = (TextView)findViewById(R.id.txt_eventName);
}
private void setListeners()
{
btnCreateEven.setOnClickListener(this);
}
#Override
public void onClick(View v)
{
switch (v.getId())
{
case R.id.btn_createEvent:
createEvents();
default:
break;
}
}
/**
* Creates a new event.
*
*
*
*/
private void createEvents()
{
try
{
Bundle params = new Bundle();
params.putString("name", "test test test");
params.putString("start_time", "2013-12-02T18:00:00+0530");
params.putString("end_time", "2013-12-02T20:00:00+0530");
params.putString("description", "This is test description 10/12/2012");
params.putString("location", "Mount Lavinia");
//params.putString("location_id", "");
params.putString("privacy_type", "OPEN");
params.putString("picture", "/sdcard/cmd.png");
mAsyncRunner.request("me/events", params, "POST", new RequestListener()
{
#Override
public void onMalformedURLException(MalformedURLException e, Object state)
{
}
#Override
public void onIOException(IOException e, Object state)
{
}
#Override
public void onFileNotFoundException(FileNotFoundException e, Object state)
{
}
#Override
public void onFacebookError(FacebookError e, Object state)
{
}
#Override
public void onComplete(String response, Object state)
{
try
{
JSONObject event = new JSONObject(response);
eventID = event.getString("id");
Log.d("createEvent:createEvent", "Event ID->" + eventID);
//Toast.makeText(getApplicationContext(), "New Event Created!!", Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
}
}
}, null);
}
catch (Exception e)
{
}
}
}
Please tell me the reason for this, any comments are welcome!
I don't see you authenticating the user anywhere. You can read about how to do that here: Facebook Authentication for Android
If you've already authenticated the user, you need to save the auth token for when you create a new Facebook object. You can readd the access token using:
facebookatEventCreate.setAccessToken(authToken);
facebookatEventCreate.setAccessExpires(unixTime);
Related
I want facebook profile information in my code. This code works Log.e("in try start", "tryyyyyyyyy"); until here but after that not even single log is executed.
private Facebook facebook;
private AsyncFacebookRunner mAsyncRunner;
String FILENAME = "AndroidSSO_data";
private SharedPreferences mPrefs;
public void loginToFacebook() {
// mPrefs = getPreferences(SharedPreferences.);
// String access_token = mPrefs.getString("access_token", null);
//long expires = mPrefs.getLong("access_expires", 0);
// if (access_token != null) {
// facebook.setAccessToken(access_token);
// }
// if (expires != 0) {
// facebook.setAccessExpires(expires);
// }
if (!facebook.isSessionValid()) {
facebook.authorize(getActivity(),
new String[] { "email", "publish_actions" },
new DialogListener() {
#Override
public void onCancel() {
// Function to handle cancel event
}
#Override
public void onComplete(Bundle values) {
// Function to handle complete event
// Edit Preferences and update facebook acess_token
Toast.makeText(getActivity(), "hiiiiii", Toast.LENGTH_SHORT).show();
//mPrefs=getSharedPreferences("data", getActivity().MODE_PRIVATE);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token",
facebook.getAccessToken());
editor.putLong("access_expires",
facebook.getAccessExpires());
editor.commit();
Log.e("getProfileInformation entry", "getProfileInformation");
getProfileInformation();
}
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
});
}
}
public void getProfileInformation() {
Toast.makeText(getActivity(), "byeeeeeee", Toast.LENGTH_SHORT).show();
Log.e("getProfileInformation start", "getProfileInformation");
mAsyncRunner.request("me", new RequestListener() {
#Override
public void onComplete(String response, Object state) {
Log.d("Profile", response);
String json = response;
try {
Log.e("in try start", "tryyyyyyyyy");
JSONObject profile = new JSONObject(json);
// getting name of the user
Log.d("profile", ""+profile);
fb_name = profile.getString("name");
// getting email of the user
fb_email = profile.getString("email");
Log.d("fb_name", "naem"+fb_name+"emial"+fb_email);
//fb_login=true;
// fb_Image = getUserPic(fb_email);
// LoginFuction();
} catch (JSONException e) {
e.printStackTrace();
Log.e("catchhhhhh", ""+e.getMessage());
}
}
public Bitmap getUserPic(String userID) {
String imageURL;
Bitmap bitmap = null;
Log.d("TAG", "Loading Picture");
imageURL = "http://graph.facebook.com/"+userID+"/picture?type=small";
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
} catch (Exception e) {
Log.d("TAG", "Loading Picture FAILED");
e.printStackTrace();
}
return bitmap;
}
#Override
public void onIOException(IOException e, Object state) {
}
#Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
}
#Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
}
#Override
public void onFacebookError(FacebookError e, Object state) {
}
});
}
This code does not give me any name or emailId.
-Hello Abhishek !
- I have tried using Facebook sdk4.+ and i am getting profile info perfectly.
-Firs of all add below code into your oncreate method before setcontentview
FacebookSdk.sdkInitialize(getApplicationContext());
-Then Create you Callbackmanager using below code:-
callbackManager = CallbackManager.Factory.create();
-Add Permissions using below code:-
permission.add("publish_actions");
-Below code is used for Login
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(final LoginResult loginResult) {
// App code
GraphRequest request = GraphRequest.newMeRequest(
act,
new GraphRequest.GraphJSONObjectCallback() {
#Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
if (!TextUtils.isEmpty(object.toString())) {
try {
JSONObject jresJsonObject = new JSONObject(object.toString());
String id = "", name = "", gender = "";
if (!(jresJsonObject.isNull("id"))) {
id = jresJsonObject.getString("id");
}
if (!(jresJsonObject.isNull("gender"))) {
gender = jresJsonObject.getString("gender");
if (gender.equals("male")) {
gender = "0";
} else {
gender = "1";
}
}
if (!(jresJsonObject.isNull("name"))) {
name = jresJsonObject.getString("name");
}
} catch (Exception e) {
}
}
Log.e("graphrequest", response.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,gender,link");
request.setParameters(parameters);
request.executeAndWait();
}
#Override
public void onCancel() {
Log.i("", "Access Token:: " + "loginResult.getAccessToken()");
}
#Override
public void onError(FacebookException exception) {
Log.i("", "Access Token:: " + "loginResult.getAccessToken()");
}
});
LoginManager.getInstance().logInWithPublishPermissions(this, permission);
-Last but no least add below code in your OnActivitResult
callbackManager.onActivityResult(requestCode, resultCode, data);
NOTE:- This is using latest Facebook sdk
-Please inform me if it is not usefull or you are still getting issue in this.
I have developed a physics based (Box2d) game for android using Processing and I want to add score sharing option to it so that the user can share his/her best score on their facebook timeline after the game. I have setup Facebook SDK in eclipse. I have searched over internet and found this solution:
public class FacebookConnector {
private static final String APP_ID = "*************";
private Facebook facebook;
private AsyncFacebookRunner mAsyncRunner;
String FILENAME = "AndroidSSO_data";
SharedPreferences mPrefs;
public FacebookConnector() {
facebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(facebook);
}
public void loginToFacebook() {
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if (access_token != null) {
facebook.setAccessToken(access_token);
}
if (expires != 0) {
facebook.setAccessExpires(expires);
}
if (!facebook.isSessionValid()) {
facebook.authorize(LocalPakistaniGames.this,
new String[] { "email",
"publish_stream" }, new DialogListener() {
public void onCancel() {
// Function to handle cancel event
}
public void onComplete(Bundle values) {
// Function to handle complete event
// Edit Preferences and update facebook acess_token
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token",
facebook.getAccessToken());
editor.putLong("access_expires",
facebook.getAccessExpires());
editor.commit();
}
public void onError(DialogError error) {
// Function to handle error
}
public void onFacebookError(FacebookError fberror) {
// Function to handle Facebook errors
}
});
}
}
public void logoutFromFacebook() {
mAsyncRunner.logout(LocalPakistaniGames.this,
new RequestListener() {
#Override
public void onComplete(String response, Object state) {
Log.d("Logout from Facebook", response);
if (Boolean.parseBoolean(response) == true) {
// User successfully Logged out
}
}
#Override
public void onIOException(IOException e, Object state) {
}
#Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
}
#Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
}
#Override
public void onFacebookError(FacebookError e, Object state) {
}
});
}
public void getProfileInformation() {
mAsyncRunner.request("me", new RequestListener() {
public void onComplete(String response, Object state) {
Log.d("Profile", response);
String json = response;
try {
JSONObject profile = new JSONObject(json);
// getting name of the user
final String name = profile.getString("name");
// getting email of the user
final String email = profile.getString("email");
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Name: " + name + "\nEmail: " + email,
Toast.LENGTH_LONG).show();
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
public void onIOException1(IOException e, Object state) {
}
public void onFileNotFoundException1(FileNotFoundException e,
Object state) {
}
public void onMalformedURLException1(MalformedURLException e,
Object state) {
}
#Override
public void onFacebookError(FacebookError e, Object state) {
}
#Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
#Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
}
#Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
});
}
public void postToWall(int level, int score) {
// post on user's wall.
String msg = "I just made new best score in Level " + level
+ ". My new Best Score is " + score + ". Beat my score!";
final Bundle parameters = new Bundle();
parameters.putString("description", msg);
parameters.putString("picture", "http://i57.tinypic.com/fui2o.png");
parameters.putString("link",
"https://www.facebook.com/LocalPakistaniGamesAndroid");
parameters.putString("name", "Local Pakistani Games");
parameters.putString("caption",
"Share this. Be a part of preserving Pakistani culture.");
LocalPakistaniGames.this.runOnUiThread(new Runnable() {
public void run() {
facebook.dialog(LocalPakistaniGames.this, "feed",
parameters, new DialogListener() {
#Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
if (values != null) {
Toast.makeText(LocalPakistaniGames.this,
"Shared successfully on your timeline!",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(
LocalPakistaniGames.this,
"Share cancelled!",
Toast.LENGTH_SHORT).show();
}
}
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
Toast.makeText(LocalPakistaniGames.this,
"Facebook Error!",
Toast.LENGTH_SHORT)
.show();
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
Toast.makeText(LocalPakistaniGames.this,
"Error!", Toast.LENGTH_SHORT)
.show();
}
#Override
public void onCancel() {
// TODO Auto-generated method stub
Toast.makeText(LocalPakistaniGames.this,
"Share cancelled!",
Toast.LENGTH_SHORT).show();
}
});
}
});
}
}
Its working fine and giving a pre-filled dialog box where user can either share or close the dialog box. I have checked and It's sharing correctly on Facebook timeline. But the problem is that it is not using Facebook app installed on the device. Its using chrome on my device to login to Facebook.
Is there any way to force it to use Facebook app for android instead of going to chrome (or any other browser)??
There are many issues with your use of the Facebook SDK, but I will jump straight to your problem.
You're using the "feed" dialog to share. This is a web dialog, which is why it's popping up a WebView (not the actual browser app). You also do not pass any session or access tokens to the feed dialog, which is why the user needs to login before they can share.
If you want to share using the Facebook app, I would recommend this doc: https://developers.facebook.com/docs/android/share
If you want to properly use the Facebook SDK (rather than the old deprecated one), please start here: https://developers.facebook.com/docs/android/getting-started/
Here is the solution to your problem. If you want to make automatic publications on facebook wall, you have to use graph api.
Also, the first thing that you have to do is login with facebook and after that, you have to do another request for permissions.
If you are using LoginManager:
LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
this line of code gives to your app the permissions to make publications in behalf to the user
Anybody has working sample code for Facebook login in Android using the code snippet mentioned in Facebook developer site ??I couldn't understand it properly.I want to get the name and profile picture of logged in user.I want my app to display the name and profile picture as long as the session is active and need to modify the details if user changed any.
Currently what i do is,saving access token and name in shared preferences on first login and saving the image in sd card and checking access token value during each app launch.If access token value is not null,then i display the name from shared preferences and profile picture from sd card.I know that this is not the right way to do this.Somebody please help me with this.
You can this https://github.com/sromku/android-simple-facebook library it is pretty well defined and can get details of methods by searching simle facebook android on google. Do whatever you want to do with facebook with this library....happy coding
Try this code
public class LoginActivity extends Activity {
private Button butLogin, butMaps, butJackpot, butAdministrator, buttonMenu;
public static String APP_ID = " paste your app_id";
public static Facebook facebook;
private AsyncFacebookRunner mAsyncRunner;
public static SharedPreferences mPrefs;
private static final String TAG = "Activity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
loginToFacebook();
}
// Method to call the Facebook login
protected void loginToFacebook() {
facebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(facebook);
mPrefs = getSharedPreferences("faceBook", MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if (access_token != null) {
facebook.setAccessToken(access_token);
}
if (expires != 0) {
facebook.setAccessExpires(expires);
}
if (!facebook.isSessionValid()) {
facebook.authorize(this, new String[] { "email", "public_profile",
"publish_stream" }, Facebook.FORCE_DIALOG_AUTH,
new DialogListener() {
#Override
public void onCancel() {
}
#Override
public void onComplete(Bundle values) {
getProfileInformation();
}
#Override
public void onError(DialogError error) {
}
#Override
public void onFacebookError(FacebookError fberror) {
}
});
} else {
getProfileInformation();
}
}
// FaceBook getting profile information
public void getProfileInformation() {
showLoadingImage();
Helper.setFacebookLogin(getApplicationContext(), true);
mAsyncRunner.request("me", new RequestListener() {
#Override
public void onComplete(String response, Object state) {
String json = response;
try {
Log.i("JSOB", json);
JSONObject profile = new JSONObject(json);
try {
Bitmap bmp = null;
URL image_value = new URL("http://graph.facebook.com/"
+ profile.getString("id")
+ "/picture?type=large");
bmp = BitmapFactory.decodeStream(image_value.openConnection().getInputStream());
profile_pic.setImageBitmap(bmp);
} catch (MalformedURLException e) {
e.printStackTrace();
}
String first_name= profile.getString("first_name"));
String last_name=profile.getString("last_name"));
String email=profile.getString("email"));
} catch (JSONException e) {
e.printStackTrace();
}
}
#Override
public void onIOException(IOException e, Object state) {
}
#Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
}
#Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
}
#Override
public void onFacebookError(FacebookError e, Object state) {
}
});
}
// faceBook login method end
}
I'm trying to create an android app that automatically sends an image on the facebook wall of the user. I've read a lot of examples on the net (also from this site) but apparently nothing seems to work for me. This is my code:
class FacebookConnection extends AsyncTask<String, String, String> {
private Exception exception;
private Facebook facebook;
private static String APP_ID = "574586632609202"; // Replace your App ID here
Activity activity;
public FacebookConnection(Activity activity)
{
this.activity = activity;
}
private void login()
{
facebook = new Facebook(APP_ID);
facebook.authorize(activity, new String[]{ "user_photos,publish_checkins,publish_actions,publish_stream"},
new DialogListener() {
#Override
public void onComplete(Bundle values) {
}
#Override
public void onFacebookError(FacebookError error) {
}
#Override
public void onError(DialogError e) {
}
#Override
public void onCancel() {
}
});
}
protected String doInBackground(String... path) {
login();
Bundle parameters = new Bundle();
parameters.putString("message", "ciao");
Bitmap bi = BitmapFactory.decodeFile(path[0]);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
parameters.putByteArray("picture", byteArray);
String response = null;
try {
facebook.request("me");
response = facebook.request("me/feed", parameters, "POST");
} catch (MalformedURLException e) {
return e.getMessage();
} catch (IOException e) {
return e.getMessage();
}
if (response == null || response.equals(""))
return "No Response..";
else
return "Message has been posted to your walll!";
}
protected void onPostExecute(String mess) {
show("DONE", mess);
}
}
NB: i use that class in the main activity on button click, i pass my main activity as parameter. The method "show" just write in a message box the string passed as parameter.
It seems that the login is ok, but when i check my facebook wall, nothing has changed.
Thank you for your help!!!
SOLVED:
I've solved my problem!!! Here is the full code:
public class FacebookConnector {
Facebook facebook;
Context context;
Activity activity;
Handler mHandler;
String[] permissions;
String path;
public FacebookConnector(String appId, Activity activity, String[] permissions) {
this.facebook = new Facebook(appId);
this.activity = activity;
this.permissions=permissions;
this.mHandler = new Handler();
}
public void setImagePath(String path) {
this.path = path;
}
public void login() {
facebook.authorize(this.activity, this.permissions, Facebook.FORCE_DIALOG_AUTH, new DialogListener() {
#Override
public void onCancel() {
Toast.makeText(activity, "Canceled", Toast.LENGTH_SHORT).show();
}
#Override
public void onComplete(Bundle values) {
postImageonWall();
Toast.makeText(activity, "Image Posted on Facebook.", Toast.LENGTH_SHORT).show();
}
#Override
public void onError(DialogError error) {
Toast.makeText(activity, "Error", Toast.LENGTH_SHORT).show();
}
#Override
public void onFacebookError(FacebookError fberror) {
Toast.makeText(activity, "Facebook Error", Toast.LENGTH_SHORT).show();
}
});}
public void postImageonWall() {
byte[] data = null;
Bitmap bi = BitmapFactory.decodeFile(path);
//Bitmap bi = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, facebook.getAccessToken());
params.putString("method", "photos.upload");
params.putByteArray("picture", data);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);
}
public void execute() {
login();
}
class SampleUploadListener implements AsyncFacebookRunner.RequestListener{
#Override
public void onComplete(String response, Object state) {
}
#Override
public void onIOException(IOException e, Object state) {
}
#Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
}
#Override
public void onMalformedURLException(MalformedURLException e, Object state) {
}
#Override
public void onFacebookError(FacebookError e, Object state) {
}
}
}
Of course you have to call the setImagePath method before to call the execute!
Greetings
Francesco
I am following this tutorial. I got as far as to the point you retrieve the access token from the savedPreferences and then created a logout button. The problem is, it seems I access_token is always correct, no matter if I logout from my app or even from Facebook app.
This is my code:
public class MainActivity extends Activity {
private String TAG = MainActivity.class.getName();
Facebook mFacebook = new Facebook("whatever");
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook);
private SharedPreferences mPrefs;
//UI elements
private ImageButton fbLoginButton;
private Button getInfoButton;
private Button fbLogoutButton;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
Log.d(TAG, "Token found. Setting token " + access_token);
mFacebook.setAccessToken(access_token);
}
if(expires != 0) {
Log.d(TAG, "Setting expire " + expires);
mFacebook.setAccessExpires(expires);
}
if(!mFacebook.isSessionValid()) {
mFacebook.authorize(this, new String[] {"email", "read_friendlists" }, new DialogListener() {
#Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", mFacebook.getAccessToken());
editor.putLong("access_expires", mFacebook.getAccessExpires());
editor.commit();
Log.d(TAG, "Logging you in");
}
#Override
public void onFacebookError(FacebookError error) {
Log.d(TAG, "Facebook error: " + error.getMessage() );
}
#Override
public void onError(DialogError e) {
Log.d(TAG, "Error: " + e.getMessage());
}
#Override
public void onCancel() {
Log.d(TAG, "User Canceled");
}
});
}
else{
Toast.makeText(this, "Already logged in", Toast.LENGTH_LONG).show();
}
fbLoginButton = (ImageButton) findViewById(R.id.buttonFBLogin);
getInfoButton = (Button) findViewById(R.id.buttonGetInfo);
fbLogoutButton = (Button) findViewById(R.id.buttonLogout);
fbLogoutButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
doLogout();
}
});
}
protected void doLogout() {
mAsyncRunner.logout(this, new RequestListener() {
#Override
public void onComplete(String response, Object state) {
Log.d(TAG, "Logging you out");
}
#Override
public void onIOException(IOException e, Object state) {}
#Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {}
#Override
public void onMalformedURLException(MalformedURLException e,
Object state) {}
#Override
public void onFacebookError(FacebookError e, Object state) {}
});
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mFacebook.authorizeCallback(requestCode, resultCode, data);
}
}
I am always getting the Already logged in Toast.Am I doing something wrong?
PS. before retrieving the access_token from sharedpreferences, the app seemed to work fine, so it's not a problem with my API key or my debug key.
Try mFacebook.logout and check reponse value. If logout is successful it will be "true". Works for me.
Don't forget about Single Sign-On feature. If you will be still logged in Facebook app it won't really logout you.