android – 如何在没有安装facebook应用程序的情况下分享到facebook的链接?

概述我已成功使用共享对话框共享到Facebook的链接. https://developers.facebook.com/docs/android/share-dialog/ 但它需要安装Facebook应用程序.那么,我如何分享facebook应用程序安装的facebook? 谢谢 Intent intent = new Intent(Intent.ACTION_SEND);intent.setT 我已成功使用共享对话框共享到Facebook的链接.

https://developers.facebook.com/docs/android/share-dialog/

但它需要安装Facebook应用程序.那么,我如何分享facebook应用程序安装的facebook?
谢谢

解决方法
Intent intent = new Intent(Intent.ACTION_SEND);intent.setType("text/plain");intent.putExtra(Intent.EXTRA_TEXT,urlToShare);// See if official Facebook app is foundboolean facebookAppFound = false;List<ResolveInfo> matches = getPackageManager().queryIntentActivitIEs(intent,0);for (ResolveInfo info : matches) {if (info.activityInfo.packagename.tolowerCase().startsWith("com.facebook")) {intent.setPackage(info.activityInfo.packagename);facebookAppFound = true;break;  }}// As fallback,launch sharer.PHP in a browserif (!facebookAppFound) { String sharerUrl = "https://www.facebook.com/sharer/sharer.PHP?u=" + urlToShare;intent = new Intent(Intent.ACTION_VIEW,Uri.parse(sharerUrl));}startActivity(intent);
总结

以上是内存溢出为你收集整理的android – 如何在没有安装facebook应用程序的情况下分享到facebook的链接?全部内容,希望文章能够帮你解决android – 如何在没有安装facebook应用程序的情况下分享到facebook的链接?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1122162.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存