I have to share a url on android default but i want a response if url is being shared or just intent is closed. I am using on activity result but when i share with gmail it return 0(CANCELED) same when i close the intent.I need this to set text shared on a text view.Here is my code.
public void executeShareLinkClick() {
Intent intentShare = new Intent(ACTION_SEND);
intentShare.setType("text/plain");
viewModel.isLinkSharedOpen.set(true);
intentShare.putExtra(Intent.EXTRA_TEXT,"My Text of the message goes here ... write anything what you want");
startActivityForResult(Intent.createChooser(intentShare, "Shared the text ..."),111);
}
public void onActivityResult(int requestCode, int resultCode, @Nullable @org.jetbrains.annotations.Nullable Intent data) {
if (resultCode==RESULT_OK){
viewModel.isLinkShared.set(true);
}else{
viewModel.isLinkShared.set(false);
}
viewModel.isLinkSharedOpen.set(false);
}