获取android中内容的共享状态

时间:2013-07-23 14:27:16

标签: android android-intent android-sharing

我想在Android中分享内容,因此我使用以下代码进行分享:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(
  android.content.Intent.EXTRA_TEXT, message);
startActivityForResult(Intent.createChooser(
  sharingIntent, "Share using"), 1000);

onActivityResult()中,我写下以下代码:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  Log.d("TAG", "::onActivityResult:" + "requestCode:" + requestCode
    + "resultCode:" + resultCode + "Data:" + data);
}

调用onActivityResult()时,resultCode始终为0

1 个答案:

答案 0 :(得分:1)

这是因为ACTION_SEND未设置为与startActivityForResult()一起使用。没有ACTION_SEND的实施者需要致电setResult(),因此很少(如果有的话)。

Any Intent action whose documentation says "Output: nothing"不适用于startActivityForResult()