을 개방하지 않는,이 같은 FacebookDialog과 함께 SDK 3.2.1을 설치하고 uiHelper을 구현 한 : publishFeedDialog()
를 들어페이스 북 공유 대화 상자이 <a href="https://developers.facebook.com/docs/android/share/" rel="nofollow">link here</a> 당으로
if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
// Publish the post using the Share Dialog
Toast.makeText(this, "if", Toast.LENGTH_LONG).show();
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(
this).setLink("https://developers.facebook.com/android")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
} else {
Toast.makeText(this, "else", Toast.LENGTH_LONG).show();
// Fallback. For example, publish the post using the Feed Dialog
publishFeedDialog();
}
내가 가진 :
private void publishFeedDialog() {
Bundle params = new Bundle();
params.putString("name", "Facebook SDK for Android");
params.putString("caption",
"Build great social apps and get more installs.");
params.putString(
"description",
"The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link", "https://developers.facebook.com/android");
params.putString("picture",
"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this,
Session.getActiveSession(), params)).setOnCompleteListener(
new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(getApplicationContext(),
"Posted story, id: " + postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(getApplicationContext(),
"Publish cancelled", Toast.LENGTH_SHORT)
.show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(getApplicationContext(),
"Publish cancelled", Toast.LENGTH_SHORT)
.show();
} else {
// Generic, ex: network error
Toast.makeText(getApplicationContext(),
"Error posting story", Toast.LENGTH_SHORT)
.show();
}
}
}).build();
feedDialog.show();
}
FacebookDialog.canPresentShareDialog
은 Fb 앱이 전화기에 설치되고 publishFeedDialog()가 호출 되더라도 항상 false가됩니다. 하지만이 후 앱이 다운됩니다.
이 해결책은 무엇입니까? 휴대 전화에 앱이있을 때 일반 Facebook 대화 상자가 표시되는 이유는 무엇입니까? (Lenevo 모델을 사용하고 있습니다.)
Facebook 앱의 버전은 무엇입니까? canPresentShareDialog는 지원하는 FB 앱의 버전에서만 true를 반환합니다. –
방금 확인했습니다. 2.2.1이며 playstore는 현재 버전이 24.X라고 말합니다! 나는 그것이 문제를 해결해야한다고 생각한다. 나중에 다시 보자. 감사. –
'이 작품! '대화 상자에 내 링크 및 설명이 표시되며'공유 버튼 '을 누르면 페이스 북에'뭔가 잘못되었으므로 다시 시도하십시오 '라고 표시됩니다. –