0

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.

Roudi
  • 1,249
  • 2
  • 12
  • 26

1 Answers1

0

Try this code

        Intent intent_share = new Intent();
        intent_share.setAction(Intent.ACTION_SEND);
        intent_share.setFlags(R.drawable.ic_share);

        intent_share.putExtra(Intent.EXTRA_TEXT, "www.googleplay.com/acount");
        intent_share.setType("text/plain");
        startActivity(Intent.createChooser(intent_share, "Share it"));
Fakhriddin Abdullaev
  • 4,169
  • 2
  • 35
  • 37