Facebook api not working in my emulator?

I have implemented login with facebook in my project. The code is below:

public class login extends Activity{
ImageView fbtn;
private SharedPreferences mPrefs;
static Facebook facebook = new Facebook("271089732997803");
String access_token;
long expires;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.yf_login1);
    mPrefs = getPreferences(MODE_PRIVATE);
    access_token = mPrefs.getString("access_token", null);
    expires = mPrefs.getLong("access_expires", 0);
    fbtn = (ImageView)findViewById(R.id.fbtn);
    fbtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            if(access_token != null) {
                facebook.setAccessToken(access_token);
                Log.v("access_token", access_token);
            }
            if(expires != 0) {
                facebook.setAccessExpires(expires);
                Log.i("expires", ""+expires);
            }
            if (!facebook.isSessionValid()) {

                facebook.authorize(login.this,new String[] {}, new DialogListener() {
                    @Override
                    public void onComplete(Bundle values) {
                        SharedPreferences.Editor editor = mPrefs.edit();
                        editor.putString("access_token", facebook.getAccessToken());
                        editor.putLong("access_expires", facebook.getAccessExpires());
                        editor.commit();

                    }


                    @Override
                    public void onFacebookError(FacebookError error) {

                    }

                    @Override
                    public void onError(DialogError e) {

                    }

                    @Override
                    public void onCancel() {

                    }
            });
            }
            else{
                 startActivity(new Intent(login.this,ChooseTeam.class));
            }

        }
    });
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data);
}

@Override
public void onResume() {    
    super.onResume();
    facebook.extendAccessTokenIfNeeded(this, null);
}

Now my question is when i click on the the fb button it will load the progress bar and after 30-40 second it returns the same page.

The most important thing is when i run the same project in my another pc it will run perfectly, opens the dialog of login for the facebook and got the value in my preferences. But in my case i cannot even get the preferences made in my data.

What will be the problem in my emulator?? I am using eclipse galilio and sdk20.

Answers


I got the solution actually my antivirus is blocked the internet for the emulator. So i have uninstalled the antivirus and run the app and it works.

Thank you all for helping me out.


Try this.... and use this Permission for Share in Facebook..

private String[] mPermissions={"publish_stream"};

mFb.authorize(SettingActivity.this, mPermissions,new com.fbintegration.Facebook.DialogListener()
                        {

                            public void onFacebookError(FacebookError e)
                            {

                            }

                                public void onError(DialogError e) 
                                {

                                }

                                public void onComplete(Bundle values) 
                                {


                                    SessionStore.save(mFb, getApplicationContext());



                                }

                            public void onCancel() 
                            {
                                // TODO Auto-generated method stub

                            }
                        });

and this is Facebook Connector Class....

public class FacebookConnector
{

    private Facebook facebook = null;
    private Context context;
    private String[] permissions;
    private Handler mHandler;
    private Activity activity;
    //private SessionListener mSessionListener = new SessionListener();;

    public FacebookConnector(String appId,Activity activity,Context context,String[] permissions) 
    {
        this.facebook = new Facebook(appId);

        SessionStore.restore(facebook, context);


        this.context=context;
        this.permissions=permissions;
        this.mHandler = new Handler();
        this.activity=activity;
    }

    public void login() 
    {
        if (!facebook.isSessionValid()) 
        {
            facebook.authorize(this.activity, this.permissions,new LoginDialogListener());
        }
    }

    /*public void logout() 
    {
        SessionEvents.onLogoutBegin();
        AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(this.facebook);
        asyncRunner.logout(this.context, new LogoutRequestListener());
    }*/

    public void postMessageOnWall(String msg)
    {
        if (facebook.isSessionValid())
        {
            Bundle parameters = new Bundle();
            parameters.putString("message", msg);
            try
            {
                //JSONObject response=Util.parseJson(facebook.request("me/feed", parameters,"POST"));
                String response = facebook.request("me/feed", parameters,"POST");
                System.out.println(response);
            } 
            catch (IOException e) 
            {
                e.printStackTrace();
            }
        }
        else
        {

        }
    }   

    private final class LoginDialogListener implements DialogListener
    {
        public void onComplete(Bundle values) 
        {
            SessionEvents.onLoginSuccess();
        }

        public void onFacebookError(FacebookError error)
        {
            SessionEvents.onLoginError(error.getMessage());
        }

        public void onError(DialogError error)
        {
            SessionEvents.onLoginError(error.getMessage());
        }

        public void onCancel() 
        {
            SessionEvents.onLoginError("Action Canceled");
        }
    }


    private class SessionListener implements AuthListener, LogoutListener
    {

        public void onAuthSucceed()
        {
            SessionStore.save(facebook, context);
        }

        public void onAuthFail(String error) {
        }

        public void onLogoutBegin() {           
        }

        public void onLogoutFinish() {
            SessionStore.clear(context);
        }
    }

    public Facebook getFacebook() 
    {
        return this.facebook;
    }
}

Need Your Help

box2dweb issue in DestroyJoint function

javascript box2d

my jsfiddle : http://jsfiddle.net/H8e9m/11/

Not getting correct value of cost function in neural network classifier with pre calculated weights. [Octave]

machine-learning octave

I'm facing this problem in my programming assignment. The formula for calculating the cost function for a neural network is: