RequestBatch.Callback onBatchCompleted() not called

Having trouble using facebook graph API library for android when sending a batch of requests.

Not getting a callback when running this code:

        RequestBatch requestBatch = new RequestBatch(requests);
        requestBatch.addCallback(new com.facebook.RequestBatch.Callback() {
            @Override
            public void onBatchCompleted(RequestBatch batch) {
                Log.e(LOG_TAG, "onBatchCompleted()");
            }
        });
        requestBatch.executeAsync();

Answers


Found the answer.

You need to set the callback for each individual request to get the batch-related callback, because onBatchCompleted callback will be called after all per-Request callbacks are called..

        for (String friend : friends) {
            MyLog.d(LOG_TAG, "Adding request for " + friend.getInterestFbId());
            String graphPath = friend + "/feed";
            Request request = new Request(session, graphPath, null, HttpMethod.GET);
            Bundle params = new Bundle();
            params.putString("fields",
                             "id,"+
                             "name,"+
                             "username,"+
                             "feed,");
            request.setParameters(params);


            // THIS IS VITAL OR THE BATCH CALLBACK WILL NEVER ARRIVE            
            request.setCallback(new com.facebook.Request.Callback() {
                @Override
                public void onCompleted(Response response) {}
            });


            requests.add(request);

        }

Need Your Help

How to pass multiple Html.DropDownList selected values from View( .aspx ) to MVC controller's action?

asp.net-mvc model-view-controller view drop-down-menu selectedvalue

I need to pass multiple data ( probably 2 Html.DropDownList's selected values ) to MVC controller action method from MVC View ( .aspx). I think it would be from somehow Html.Hidden form , but how?

How to display Error message into chart in asp chart controls

c# asp.net aspchart

I have a chart where I have to display message as "No Data Present",when rows.count == 0

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.