我已在我的应用程序中成功实施了Facebook SDK的ShareButton
。当我安装了正式的Facebook应用程序时,ShareButton
可以正常工作。但是当我没有官方应用时,ShareButton
会打开WebDialog
。
我的问题:
每当我使用WebDialog分享任何帖子时,它会提示打开浏览器。帖子已成功共享,但WebDialog
仍提示打开浏览器。
的截图:
1)这是WebDialog
2)这是我在分享职位后得到的。
代码:
public class FragmentDetails extends Fragment
{
ShareButton facebookShareButton;
CallbackManager callbackManager;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_details, container, false);
facebookShareButton = (ShareButton) view.findViewById(R.id.fragmentDetails_FacebookShare);
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://developers.facebook.com"))
.build();
facebookShareButton.setShareContent(content);
return view;
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getContext());
callbackManager = CallbackManager.Factory.create();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
}