我遇到了一个不同的错误。我尝试执行 Facebook 共享对话框,但在 logcat 中遇到此错误。
10-17 15:44:39.026: E/AndroidRuntime(2534): com.facebook.FacebookException: Unable to create Intent; this likely means the Facebook app is not installed.
我不知道这是什么意思。我试图搜索它,但没有类似的实例。这是我的代码。
TabFour.java
public class TabFour extends Fragment {
private UiLifecycleHelper uiHelper;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_tab_four, container, false);
return rootView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("book", "https://example.com/book/Snow-Crash.html");
@SuppressWarnings("deprecation")
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "books.reads", "book")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback() {
@Override
public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) {
Log.e("Activity", String.format("Error: %s", error.toString()));
}
@Override
public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
Log.i("Activity", "Success!");
}
});
}
@Override
public void onResume() {
super.onResume();
uiHelper.onResume();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
}
@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
// TODO Auto-generated method stub
}
};
}
这是我的日志: