나는 Facebook에서 몇 가지 것을 공유하려고합니다. 다음은 guide 네이티브 앱을 가지고있을 때 공유를 완료했습니다. 그러나 도달했을 때 :기본 앱이 설치되지 않은 상태에서 Facebook에서 공유하기
4 단계 : 대체 대화 상자로 피드 대화 상자 사용 그것은 대체 방법을 사용 할 수 있다고, 나는이를 추가 한 후
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();
}
아래의 코드를 추가 할 필요가, 내가 getActivity()
에서 오류를 얻을, 나는 MyClass.this
를 사용하여이 문제를 해결. 그런 다음 응용 프로그램을 실행할 때 (시작시이 메서드를 직접 실행) 응용 프로그램이 충돌하고 "열려 있지 않은 세션을 사용하려고했습니다"라는 오류가 발생합니다.
아무 것도없이 공유 할 수있는 방법을 알고 있습니다. 기본 앱이 설치 되었습니까?
답변 해 주셔서 감사합니다. 나는이 대답을 최대한 빨리 시험해 볼 것이다. 그리고 돌아와서 그것이 효과가 있었다면 받아 들여라. – Val