android - 共享按钮不与 facebook 一起运行(文本为空)
问题描述
共享按钮与 Viber 和 What's 应用程序一起运行,但不与 Facebook 一起运行,只是空白区域。
Intent myIntent = new Intent(Intent.ACTION_SEND);
bt = findViewById(R.id.imageShareButton);
bt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String shareBody = versesText.getText().toString();
myIntent.setType("text/plain");
myIntent.putExtra(Intent.EXTRA_SUBJECT, "Perfect Verses");
myIntent.putExtra(Intent.EXTRA_TEXT, shareBody + "\n" + "Read More...");
myIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(myIntent, getResources().getString(R.string.app_name)));
}
});
我的应用在 GooglePlay 上的链接, https://play.google.com/store/apps/details? id=com.samuel.perfectverses
解决方案
String packageName = "com.facebook.katana";
String fullUrl = "https://m.facebook.com/sharer.php?u=..";
Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
if (intent == null) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(fullUrl));
startActivity(i);
} else {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setClassName(packageName ,
"com.facebook.katana.ShareLinkActivity");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "your title text");
startActivity(sharingIntent);
推荐阅读
- javascript - 如何检查一个对象属性是否也存在于另一个对象中?
- java - Android(Java)中的一叠卡片(类似纸牌)
- java - 从文件中读取的 java 代码应该读取完整的文件,但不会
- javascript - 为什么我的邮递员没有显示我的架构成立时间和收入?
- python - 如何将 DataFrame 与 if 条件进行比较?
- google-apps-script - 如何使用多个单元格作为电子邮件正文、Google 表格
- php - 当 MariaDB 查询超时时 PHP 不会抛出异常
- latex - RStudio Tabularx 表格未居中
- upgrade - TYPO3 : 扩展从版本 7 升级到 9
- python - 使用python检查zip文件中的任何文件夹