How to startActivity with a ShareCompat.IntentBuilder

ShareCompat.IntentBuilder.from(ActivityName.this) is deprecated, use the constructor of IntentBuilder like this:

Kotlin:

    ShareCompat
               .IntentBuilder(this@YourActivity)
               .setType("text/plain")
               .setChooserTitle("Share text with: ")
               .setText("Desired text to share")
               .startChooser()

Java:

new ShareCompat
                .IntentBuilder(YourActivity.this)
                .setType("text/plain")
                .setChooserTitle("Share text with: ")
                .setText("Desired text to share")
                .startChooser();

Thats an example from my code, but if you want some reference material tap on the hyperlink for an article.

public void shareText(String text) {
        String mimeType = "text/plain";
        String title = "Example title";

        Intent shareIntent =   ShareCompat.IntentBuilder.from(this)
                                                    .setType(mimeType)
                                                    .setText(text)
                                                    .getIntent();
        if (shareIntent.resolveActivity(getPackageManager()) != null){
            startActivity(shareIntent);
        }
    }

Blog post on ShareCompat.IntentBuilder and sharing intents