【问题标题】:How to ensure if the user shared the ttext to meesaging apps如何确保用户是否将文本共享到消息传递应用程序
【发布时间】:2017-03-24 19:52:08
【问题描述】:

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

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);

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

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

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

【问题讨论】:

    标签: android sharing


    【解决方案1】:

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

    ACTION_SEND 不支持startActivityForResult()。没有ACTION_SEND 活动应该调用setResult() 来返回结果。

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

    你不能。用户选择的应用程序内部发生的事情取决于用户和其他应用程序的开发人员,而不是您。

    【讨论】:

      猜你喜欢
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多