1
这是第一次在android中使用facebook SDK,所以在使用Facebook登录我的应用程序之后!我取回我的invitable_friends,并显示在列表视图在android中使用facebook SDK,如何邀请朋友?
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/invitable_friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
JSONObject object = new JSONObject(response.getRawResponse());
JSONArray array = object.getJSONArray("data");
for (int i = 0; i < array.length(); i++) {
JSONObject jsonObject = array.getJSONObject(i);
String id = jsonObject.optString("id");
String name = jsonObject.optString("name");
String url = jsonObject.optJSONObject("picture").optJSONObject("data").optString("url");
Person person = new Person(id,name,url);
person.setId(id);
person.setName(name);
person.setUrl(url);
list.add(person);
}
} catch (JSONException e) {
e.printStackTrace();
}
listView.setAdapter(new FriendsAdapter(getApplicationContext(),list));
现在我需要将邀请发送给我的朋友点击时要使用我的应用程序。
,所以我把手上OnItemClickListener
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String appLinkUrl;
appLinkUrl = "Application Link";
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.build();
AppInviteDialog.show(FriendsList.this, content);
}
}
});
}
}
).executeAsync();
和我跟踪与过程的成功或失败
appInviteDialog = new AppInviteDialog(this);
appInviteDialog.registerCallback(callbackManager, new FacebookCallback<AppInviteDialog.Result>() {
@Override
public void onSuccess(AppInviteDialog.Result result) {
Log.d("Yehia","onSuccess result = "+ result.getData().toString());
}
@Override
public void onCancel() {}
@Override
public void onError(FacebookException e) {
Log.d("Yehia","onError message = "+ e.getMessage());
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
,但遗憾的是始终的onError叫来! 我知道我有一些误解。 可以任何身体帮助我! 注意:我的链接应用程序不起作用! 在此先感谢。
请发布您的完整logcat @Mohamed Yehia – Lampard