安卓Facebook SDK
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这很简单......在工厂中创建一个字符串变量就搞砸了。后来,同一天我看到了这一点,并调用了 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.