share text To Other App via Intent - Android Intent

Android examples for Intent:Image Share

Description

share text To Other App via Intent

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.Intent;

public class Main {

    public static void shareToOtherApp(Context context, String title,
            String content, String dialogTitle) {
        Intent intentItem = new Intent(Intent.ACTION_SEND);
        intentItem.setType("text/plain");
        intentItem.putExtra(Intent.EXTRA_SUBJECT, title);
        intentItem.putExtra(Intent.EXTRA_TEXT, content);
        intentItem.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(Intent.createChooser(intentItem, dialogTitle));
    }//from  w w w .j a v  a  2 s.  c o m
}

Related Tutorials