我想将文本共享给另一个应用程序,并希望如果文本成功发送,则导致代码等于 1,否则导致代码等于 0,如果结果代码等于 1,则执行某些操作,但 ACTION_SEND 不返回任何内容。你知道吗?
shareimg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, headertext.getText().toString() );
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, share );
startActivityForResult(Intent.createChooser(sharingIntent, "به اشتراک گذاری "),sharerequstresultcode);
}
});
和 onActivityResult:
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == sharerequstresultcode) {
Toast.makeText(getApplicationContext(),"submit",Toast.LENGTH_SHORT).show();
}
}