我想在 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
。