如何确保用户是否将文本共享给消息传递应用程序

How to ensure if the user shared the ttext to meesaging apps

使用此代码,我可以将一些文本分享到任何消息传递应用程序

String shareBody = getString(R.string.someText);
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivityForResult(Intent.createChooser(sharingIntent, "share_using"),ShareSth);

现在,如果用户是否分享了文本,我如何获得结果?

我使用了 resultCode 为 0 的 onActivityResult,这意味着用户已取消但实际上它是共享的

public void onActivityResult(int requestCode, int resultCode, Intent data) {
{
   //resultCode is 0 which means user canceled but really it is shared 
}

Using this code I share some text to any messaging app

ACTION_SEND不支持startActivityForResult()。没有 ACTION_SEND 活动应该调用 setResult() 到 return 结果。

How I can get the result if user has shared the text or not ?

你不能。用户选择的应用程序内部会发生什么取决于用户和其他应用程序的开发者,而不是你。