What I am using:
ShareCompat.IntentBuilder
.from(getActivity())
.setText("text")
.setType("text/plain")
.startChooser();
I also tried the below:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, url);
sendIntent.setType("text/plain");
context.startActivity(sendIntent);
On all my emulators, versions from 5 to 7. In both above codes, the intent would open and the text I am trying to share works successfully.
Nexus 5X, HTC One M8 both work too. However, when I use a Samsung device, version 5 and 7 do not open anything when I call both codes above.
EDIT
I turned off battery optimization on the Samsung with android version 5 and it worked? I then disabled it again but it kept working.