[英]using facebook SDK in android , How to invite friend?
It's the first time to work with facebook SDK in android , so after signed in my application using facebook ! 这是第一次在android中使用facebook SDK,所以在使用facebook登录我的应用程序之后! i retrieved my invitable_friends and show them in a listView
我检索了我的invitable_friends并在listView中显示它们
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));
now i need to send invitation to my friend to use my application when clicked . 现在,我需要向我的朋友发送邀请,以便在点击时使用我的应用程序。
so i handle that on OnItemClickListener 所以我在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();
and i keep track with the process success or failure 我跟踪流程的成功或失败
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);
}
but Unfortunately always onError Called ! 但很遗憾总是onError被叫! i know that i have some misunderstanding .
我知道我有一些误解。 can any body help me !
有谁能够帮助我 ! NOTE : my link application does not work yet !
注意:我的链接应用程序尚未运行! thanks in advance .
提前致谢 。
实际上,当我将它切换到v4.0.0时,我正在使用SDK v4.11.0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.