安卓Facebook SDK

发布于 2024-12-16 12:58:08 字数 812 浏览 7 评论 0原文

我正在使用 Android Facebook SDK,想要获取好友列表。我创建了一个“AsyncTask”来完成这样的事情。我将我的 doInBackgroundMethod 粘贴到此处。

@Override
    protected String doInBackground(String... url) {
        String jsonResponse;
        try {
            jsonResponse =     Factory.getFacebook().request(Utils.LOGGEDIN_USER_FRIENDS);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
        return jsonResponse;
    }

Utils Code

public static final String LOGGEDIN_USER_FRIENDS = "me/friends";

我遇到的问题是应用程序第一次运行时返回一个空的 jsonResponse 。当我第二次打开应用程序时,我收到了 JsonResponse。但我第一次得到空的 jsonResponse。

任何人都可以在这方面帮助我吗?

I am working with Android Facebook SDK and wanted to get a friends list. I have created an "AsyncTask" for doing such a thing. I am pasting my doInBackgroundMethod here.

@Override
    protected String doInBackground(String... url) {
        String jsonResponse;
        try {
            jsonResponse =     Factory.getFacebook().request(Utils.LOGGEDIN_USER_FRIENDS);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
        return jsonResponse;
    }

Utils Code

public static final String LOGGEDIN_USER_FRIENDS = "me/friends";

The problem I am running in to is that it is returning an empty jsonResponse for the first time the application runs. When I open my app the second time I am getting the JsonResponse. But for the first time however I am getting empty jsonResponse.

Can any one help me out in this regard.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

今天小雨转甜 2024-12-23 12:58:08

嗯,这很简单......在工厂中创建一个字符串变量就搞砸了。后来,同一天我看到了这一点,并调用了 AsyncTask 内置方法 get ,它在同一线程中提供结果。

Well it was easy... It was messed up by creating a String variable in a Factory. Later on, the same day I saw that, and called the AsyncTask built in method get which provides the result in the same thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文