Example usage for android.content Intent EXTRA_SUBJECT

List of usage examples for android.content Intent EXTRA_SUBJECT

Introduction

In this page you can find the example usage for android.content Intent EXTRA_SUBJECT.

Prototype

String EXTRA_SUBJECT

To view the source code for android.content Intent EXTRA_SUBJECT.

Click Source Link

Document

A constant string holding the desired subject line of a message.

Usage

From source file:am.project.x.utils.ContextUtils.java

/**
 * ???/*from   w  ww.j a va2 s  .  c om*/
 *
 * @param context    Context
 * @param subject    
 * @param attachment 
 * @param addresses  ?
 */
public static void sendEmail(Context context, @Nullable String subject, @Nullable Uri attachment,
        String... addresses) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    if (subject != null)
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (attachment != null)
        intent.putExtra(Intent.EXTRA_STREAM, attachment);
    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);
    }
}

From source file:com.ox.utils.IntentUtils.java

/**
 * send email/*from   ww w. j  a v  a2  s.c  o  m*/
 *
 * @param email email address
 */
public static void sendEmail(Context context, String email) {
    Intent data = new Intent(Intent.ACTION_SENDTO);
    data.setData(Uri.parse("mailto:" + email));
    data.putExtra(Intent.EXTRA_SUBJECT, "[ " + AppUtils.getApplicationName(context) + " ] " + "??");
    ComponentName componentName = data.resolveActivity(context.getPackageManager());
    if (componentName != null) {
        context.startActivity(data);
    } else {
        Toast.makeText(context, "", Toast.LENGTH_SHORT).show();
    }
}

From source file:com.example.linhdq.test.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(Context context, String subject, File file, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }/*from  w  w w.  j  av a  2 s .  com*/
    if (file.exists()) {
        final Uri uriForFile = FileProvider.getUriForFile(context,
                context.getString(R.string.config_share_file_auth), file);
        intent.putExtra(Intent.EXTRA_STREAM, uriForFile);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}

From source file:com.renard.ocr.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(Context context, String subject, File file, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    }/*from  w  w  w.j a  va  2s. com*/
    if (file.exists()) {
        final Uri uriForFile = FileProvider.getUriForFile(context,
                context.getString(R.string.config_share_file_auth), file);
        intent.putExtra(Intent.EXTRA_STREAM, uriForFile);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}

From source file:com.hch.beautyenjoy.tools.IntentUtils.java

/**
 * send email//from w  ww.  j  a  va 2s.  c  om
 *
 * @param email email address
 */
public static void sendEmail(Context context, String email) {
    Intent data = new Intent(Intent.ACTION_SENDTO);
    data.setData(Uri.parse("mailto:" + email));
    data.putExtra(Intent.EXTRA_SUBJECT, "[ " + AppTools.getApplicationName(context) + " ] " + "??");
    ComponentName componentName = data.resolveActivity(context.getPackageManager());
    if (componentName != null) {
        context.startActivity(data);
    } else {
        Toast.makeText(context, "", Toast.LENGTH_SHORT).show();
    }
}

From source file:ca.rmen.android.scrumchatter.export.Export.java

/**
 * Bring up the chooser to send the file.
 *///from ww  w.  ja  v  a  2  s  .  c om
static void share(Context context, File file, String mimeType) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.export_message_subject));
    sendIntent.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.export_message_body));
    Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", file);
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    sendIntent.setType(mimeType);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(sendIntent,
                PackageManager.MATCH_DEFAULT_ONLY);
        for (ResolveInfo resolveInfo : resInfoList) {
            String packageName = resolveInfo.activityInfo.packageName;
            context.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
            Log.v(TAG, "grant permission to " + packageName);
        }
    }
    context.startActivity(
            Intent.createChooser(sendIntent, context.getResources().getText(R.string.action_share)));
}

From source file:com.phunkosis.gifstitch.helpers.ShareHelper.java

public static void startShareLinkIntent(Activity activity, String url) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, activity.getResources().getString(R.string.share_link_body) + " " + url);
    intent.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.share_link_subject));
    intent.setType("text/plain");
    activity.startActivity(Intent.createChooser(intent, "Share "));
}

From source file:im.delight.android.baselib.Social.java

/**
 * Constructs an Intent for sharing/sending plain text and starts Activity chooser for that Intent
 *
 * @param context Context reference to start the Activity chooser from
 * @param windowTitle the string to be used as the window title for the Activity chooser
 * @param messageText the body text for the message to be shared
 * @param messageTitle the title/subject for the message to be shared, if supported by the target app
 *//*  www .  j  a  va  2s . c o m*/
public static void shareText(Context context, String windowTitle, String messageText, String messageTitle) {
    Intent intentInvite = new Intent(Intent.ACTION_SEND);
    intentInvite.setType(HTTP.PLAIN_TEXT_TYPE);
    intentInvite.putExtra(Intent.EXTRA_SUBJECT, messageTitle);
    intentInvite.putExtra(Intent.EXTRA_TEXT, messageText);
    context.startActivity(Intent.createChooser(intentInvite, windowTitle));
}

From source file:com.activiti.android.platform.intent.IntentUtils.java

/**
 * Allow to send a link to other application installed in the device.
 *
 * @param fr/*  w  w w  .ja  v  a 2  s. com*/
 * @param url
 */
public static void actionShareLink(Fragment fr, String title, String url) {
    try {
        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("text/plain");
        i.putExtra(Intent.EXTRA_SUBJECT, title);
        i.putExtra(Intent.EXTRA_TEXT, url);
        fr.startActivity(Intent.createChooser(i, fr.getActivity().getText(R.string.task_action_share_link)));
    } catch (ActivityNotFoundException e) {

    }
}

From source file:com.renard.ocr.help.ContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contact);
    // Show the Up button in the action bar.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    TextView email = (TextView) findViewById(R.id.textView_send_mail);
    email.setOnClickListener(new OnClickListener() {

        @Override// w w w. j  a va2  s .co m
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("message/rfc822");
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "text fairy feedback");
            intent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { "renard.wellnitz+textfairy@googlemail.com" });
            startActivity(intent);
        }
    });

}