0

i try to login to facebook and post to wall with one button click.. i wrote some code and app can to login and post to wall but i have one problem

http://s33-temporary-files.radikal.ru/f593da0cfa4048d792c1cc4a694bc5af/-88693455.png

this permishens seen two times. 1)when i login on facebook 2)when i login a facebook and click ok this permishen seen again (two times) this is a my code if anyone can solution my problem please help me thanks

FaceBookButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!fb.isSessionValid()) {
                fb.authorize(Result.this, PERMISSIONS,
                        new TestPostListener());
            }

        }
    });
}

public class TestPostListener implements DialogListener {

    public void onComplete(Bundle values) {
        try {
            callFacebook(tittle.getText().toString());
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    public void onCancel() {
    }

    public void onError(DialogError e) {
        e.printStackTrace();
    }

    public void onFacebookError(FacebookError e) {
        e.printStackTrace();
    }
}

public void callFacebook(final String title) {
    android.util.Log.i("FB", "callFacebook");
    fb.authorize(Result.this, new DialogListener() {
        @Override
        public void onComplete(Bundle values) {
            android.util.Log.i("#### FB", "onComplete");
            if (values.isEmpty()) {
                return;
            }
            if (!values.containsKey("post_id")) {
                android.util.Log.i("#### FB", "not post_id");
                try {
                    Bundle parameters = new Bundle();
                    parameters.putString("message", "this is a test");


                    parameters.putString("name", title);
                    parameters.putString("link","http://stackoverflow.com");
                    fb.dialog(Result.this, "stream.publish", parameters,
                            this);
                } catch (Exception e) {

                    android.util.Log.i("#### FB", e.getMessage());
                }
            }
        }

        @Override
        public void onFacebookError(FacebookError error) {
            android.util.Log.i("#### FB", "FacebookError: " + error);
        }

        @Override
        public void onError(DialogError e) {
            android.util.Log.i("#### FB", "DialogError: " + e);
        }

        @Override
        public void onCancel() {
            android.util.Log.i("#### FB", "cancel");
        }
    });
}

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

    fb.authorizeCallback(requestCode, resultCode, data);

}

1 Answer 1

0

I have no knowledge of the FB api but you call facebook.authorize each time you invoke callFacebook. I guess it will ask the user to authorize and since he already has, the screen is shown again with the message above.

Change your checks so that you don't authorize every time.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.