. 제안 된 방법은 먼저 공유 대화 상자를 표시하고 표시 할 수 있는지 여부를 확인하고 콘텐츠를 표시하거나 웹 대화 상자를 사용하여 공유 화면을 표시하는 것입니다. 즉 여기
if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.SHARE_DIALOG))
{
// Publish the post using the Share Dialog
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
.setLink("https://developers.facebook.com/android")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
else
{
// Fallback. For example, publish the post using the Feed Dialog
}
그리고
는 다른 옵션의 예를
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(getActivity(),
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(getActivity(),
"Posted story, id: "+postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(getActivity().getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(getActivity().getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
} else {
// Generic, ex: network error
Toast.makeText(getActivity().getApplicationContext(),
"Error posting story",
Toast.LENGTH_SHORT).show();
}
}
})
.build();
feedDialog.show();
}
입니다 그리고 항상 물건을 확인하기위한 에뮬레이터에 의존하지 않습니다. 결국 그 "에뮬레이터". 실제 장치에서 앱을 쉽게 미리 볼 수 있습니다. 따라서 에뮬레이터에서 실제 장치에서 확인해야하는대로 실행되지 않는 경우. (물론, 필자는 동의합니다. 에뮬레이터는 여러 장치, 화면 크기 등이 없을 때 좋습니다.)
PS : fb 개발자 웹 사이트의 앱 설정 페이지에서 키 해시를 올바르게 설정해야합니다.
에뮬레이터에 페이스 북 앱이 있습니까? 또한 페이 스북 응용 프로그램의 버전을 확인하십시오. 어떤 adb 오류 로그를 볼 수 있습니까? –