Es ist das erste Mal mit Facebook SDK in Android zu arbeiten, also nach meiner Anmeldung in Facebook! i abgerufen meine invitable_friends und zeigen sie in einem Listviewmit Facebook SDK in Android, wie man Freund einlädt?
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));
jetzt ich brauche Einladung zu meinem Freund senden meine Anwendung zu verwenden, wenn sie angeklickt.
so handhaben ich, dass auf 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();
und ich verfolgen, mit dem Prozess Erfolg oder Misserfolg
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);
}
aber leider immer onError Called! Ich weiß, dass ich ein Missverständnis habe. kann mir jeder Körper helfen! HINWEIS: meine Link-Anwendung funktioniert noch nicht! danke im voraus.
Bitte posten Sie Ihren vollständigen Logcat @Mohamed Yehia – Lampard