ShareCompat.IntentBuilder in Android

IntentBuilder is a helper for constructing ACTION_SEND and ACTION_SEND_MULTIPLE sharing intents and starting activities to share content. The ComponentName and package name of the calling activity will be included.

Source : https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentBuilder.html


A choose dialog appears from the bottom of the screen showing all the apps on the device that are able to handle this type of the intent.

// TODO (1) Create a void method called shareText that accepts a String as a parameterpublic void shareText(String text) {
    // Do steps 2 - 4 within the shareText method
    // TODO (2) Create a String variable called mimeType and set it to "text/plain"
String mimeType = "text/plain";
    // TODO (3) Create a title for the chooser window that will pop up
String title = "First Share Text";
    // TODO (4) Use ShareCompat.IntentBuilder to build the Intent and start the choose
ShareCompat.IntentBuilder.from(this)
            .setChooserTitle(title)
            .setType(mimeType)
            .setText(text).startChooser();}

Yorumlar

Bu blogdaki popüler yayınlar

About Android padding, margin, width, height, wrap_content, match_parent, R Class

@SerializedName and @Expose annotations