gpt4 book ai didi

android - Facebook 共享对话框中的错误

转载 作者:行者123 更新时间:2023-11-29 14:18:08 24 4
gpt4 key购买 nike

我遇到了一个不同的错误。我尝试执行 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

}
};

}

这是我的日志:

http://shrib.com/nointentstuff

最佳答案

对于那些真正想为可能没有安装 Facebook 应用程序的用户构建应用程序的人,请确保在您的 ShareDialog 构建器 ( more info here ) 周围包含此检查:

if (FacebookDialog.canPresentShareDialog(getApplicationContext(), 
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
.setLink("https://developers.facebook.com/android")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());

}

关于android - Facebook 共享对话框中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19486602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com