本文介绍了Android的 - 创建一个新的Facebook相册创建两张专辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code创建一个新的Facebook相册。它的工作原理 - 但它创造了专辑的两倍!它仅在一个地方被调用,它不从其他地方称为

I am using the following code to create a new facebook album. It works - but it creates the album twice! It is only called from one place, it is not called from anywhere else.

我撕裂我的头发试图找出为什么发生这种情况。难道是与会话?创建新专辑code是呼吁在OnCreate()

I am tearing my hair out trying to work out why this is happening. Could it be something to do with the Session? The Create New Album code is called on a button click in the OnCreate()

 mButtonPost.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            createNewAlbum(Session.getActiveSession(), "new album for photos");
        }

    });

这是code创建相册:

This is the code to create the album:

public void createNewAlbum(Session session, String albumName) {
if (session.isOpened()) {

    SessionState state = session.getState();
    if (state.isOpened()) { //added this 

    Bundle params = new Bundle();
    params.putString("name", albumName);

    Request.Callback callback = new Request.Callback() {

        @Override
        public void onCompleted(Response response) {

            // use response id to upload photo to that album
            errText.setText("New Album created response: " + response.toString());

            //need to get the newly created album ID.
            try
            {
                JSONObject graphResponse =response.getGraphObject().getInnerJSONObject();

                try
                {
                    albID = graphResponse.getString("id");

                    //UPLOAD photos to that album
                    UploadToAlbum(Session.getActiveSession(), albID);
                }
                catch (JSONException e)
                {
                    Log.d( "JSON error "+ e.getMessage(), albID );
                    albID =null;
                }

            }
            catch (Exception e) {
                e.printStackTrace();
                albID = null;
            }
        }
    };


    Request request = new Request(session, "me/albums",params, HttpMethod.POST,callback);
    request.executeAsync();

    }//end state session is opened

    }//end session if
}

有什么明显的在这里?
当活动负荷,我称之为LogInToFacebook()。
然后点击按钮和专辑创建。
但它被创建两次。两个空相册的创建和都具有相同的ID。如果没有什么明显的这里,那么我会后我的登录code作为过我真不明白它。

Is there anything obvious here?When the Activity loads, I call "LogInToFacebook()".Then the button is clicked and the album is created.But it is created twice. Two empty albums are created and both have the SAME ID. If there is nothing obvious here then I will post my login code too as I really don't understand it.

推荐答案

原来这是Facebook的GraphAPI一个大错误-the已分配给团队来解决,但谁知道它可能是多久其固定之前!

Turns out this is a big in Facebooks GraphAPI -the bug has been assigned to the team to fix, but who knows how long it could be before its fixed!

这篇关于Android的 - 创建一个新的Facebook相册创建两张专辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 15:24