Click here to Skip to main content
14,738,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have following code to call facebook login dialogue in my android application,

public void loginToFacebook() {
   if (access_token != null) {

   if (expires != 0) {

   if (!facebook.isSessionValid()) {
         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
               AsyncCallFacebookCredentials task1 = new AsyncCallFacebookCredentials();
               SharedPreferences.Editor editor = mPrefs.edit();
               editor.putString("LoginStatus", "on");
               editor.putString("access_token", facebook.getAccessToken());
               fbAccessToken_edit.putString("fbAccessToken", facebook.getAccessToken());
               editor.putLong("access_expires", facebook.getAccessExpires());
               Intent intent = new Intent(Register.this, MainActivity.class);

            public void onError(DialogError error) {
               // Function to handle error

            public void onFacebookError(FacebookError fberror) {
               // Function to handle Facebook errors


i am using above function in two activities, two activities have exactly same code as above, but in one activity it works perfectly but in other activity the login dialogue takes too much time to appear and after appearing if i enter credentials and press login button nothing happens.

Please help

[edit]Code block added and indexation optimized[/edit]
Updated 15-Feb-14 2:54am
Richard MacCutchan 15-Feb-14 7:52am
You have two OnError methods which do nothing, other than consume the errors, so you have no way of knowing when failures occur.
ShreenivasCh 15-Feb-14 10:26am
i have tried by removing comments in OnError methods and written code get error message in log cat but i didnt get any error message

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900