gpt4 book ai didi

android - 共享 Action 提供者 :How to know which app is sharing the content?

转载 作者:行者123 更新时间:2023-11-29 01:46:38 26 4
gpt4 key购买 nike

大家好,我认为这个问题不言自明。问题是我想在不同的应用程序上分享不同的内容。我正在使用下面的代码来共享工作正常的内容。但是所有应用程序上的共享内容都是相同的。但是我尝试搜索一下谷歌,似乎没有关于如何在不同应用程序上共享不同内容的文章?我不认为代码是必需的,但如果有人需要它,就在这里。

public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.item_display_menu, menu);
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_solid_reggys));
mShareActionProvider = (ShareActionProvider) menu.findItem(
R.id.shareButton).getActionProvider();
Intent intent = getDefaultShareIntent();
if (intent != null)
mShareActionProvider.setShareIntent(intent);
return super.onCreateOptionsMenu(menu);

}

最佳答案

您需要使用两个不同的 Intent 来共享不同的内容(以及两个不同的用户可点击按钮)。这是因为 mShareActionProvider.setShareIntent(intent); 只需要一个 Intent

通常这是正确的行为,因为您正在执行诸如“共享文本”或“共享图像”之类的操作,如果您需要检测您正在共享到哪个应用程序,它不再是通用的。

关于android - 共享 Action 提供者 :How to know which app is sharing the content?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21066469/

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