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:im.delight.android.commons.Social.java

/**
 * Displays an application chooser and shares the specified plain text and subject line using the selected application
 *
 * @param context a context reference//from   w  w  w .ja v a2s . c o  m
 * @param windowTitle the title for the application chooser's window
 * @param bodyTextToShare the body text to be shared
 * @param subjectTextToShare the title or subject for the message to be shared, if supported by the target application
 */
public static void shareText(final Context context, final String windowTitle, final String bodyTextToShare,
        final String subjectTextToShare) {
    final Intent intentInvite = new Intent(Intent.ACTION_SEND);
    intentInvite.setType(HTTP.PLAIN_TEXT_TYPE);
    intentInvite.putExtra(Intent.EXTRA_SUBJECT, subjectTextToShare);
    intentInvite.putExtra(Intent.EXTRA_TEXT, bodyTextToShare);

    context.startActivity(Intent.createChooser(intentInvite, windowTitle));
}

From source file:com.github.akinaru.bleanalyzer.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object/*from  ww w.  j  a va2 s .  co m*/
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context,
        IBtActivity activity) {

    switch (menuItem.getItemId()) {
    case R.id.switch_chart_data: {
        break;
    }
    case R.id.rfdroid: {
        Intent i = new Intent(context, RFdroidActivity.class);
        context.startActivity(i);
        break;
    }
    case R.id.scan_btn_nv: {
        if (activity != null)
            activity.toggleScan();
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", context.getResources().getString(R.string.email_addr), null));
        intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_subject));
        intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.report_hint));
        context.startActivity(
                Intent.createChooser(intent, context.getResources().getString(R.string.issue_title)));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog(context);
        d.show();
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:com.github.longkai.zhihu.util.Utils.java

/**
 * ??/*www  .ja  v  a2  s  . c  om*/
 * @param context
 * @param subject 
 * @param content 
 * @return intent
 */
public static Intent share(Context context, String subject, String content) {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    share.putExtra(Intent.EXTRA_SUBJECT, subject);
    share.putExtra(Intent.EXTRA_TEXT, content + context.getString(R.string.share_from));
    return share;
}

From source file:at.jclehner.appopsxposed.BugReportBuilder.java

public static void buildAndSend(final Context context) {
    if (!SU.available()) {
        Toast.makeText(context, R.string.toast_needs_root, Toast.LENGTH_SHORT).show();
        return;/*w w w .j ava 2  s .  c  om*/
    }

    Toast.makeText(context, R.string.building_toast, Toast.LENGTH_LONG).show();

    final BugReportBuilder brb = new BugReportBuilder(context);

    new AsyncTask<Void, Void, Uri>() {

        @Override
        protected Uri doInBackground(Void... params) {
            return brb.build();
        }

        @Override
        protected void onPostExecute(Uri result) {
            final ArrayList<Parcelable> uris = new ArrayList<Parcelable>();
            uris.add(result);

            final Intent target = new Intent(Intent.ACTION_SEND_MULTIPLE);
            target.setType("text/plain");
            target.putExtra(Intent.EXTRA_SUBJECT,
                    "[REPORT][AppOpsXposed " + Util.getAoxVersion(context) + "] " + Build.FINGERPRINT);
            target.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            //target.putExtra(Intent.EXTRA_STREAM, result);
            target.putExtra(Intent.EXTRA_TEXT, "!!! BUG REPORTS WITHOUT ADDITIONAL INFO WILL BE IGNORED !!!");
            //target.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            final Intent intent = Intent.createChooser(target, null);
            //intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            context.startActivity(intent);
        }
    }.execute();
}

From source file:cc.softwarefactory.lokki.android.fragments.AboutFragment.java

private void openTellAFriendActivity() {
    try {/*from  w  ww. j  a v  a 2  s .c om*/
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_subject));
        intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text));
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Couldn't open 'tell a friend about lokki' activity");
    }
}

From source file:com.app.common.util.IntentUtils.java

public static void startEmailActivity(Context context, String to, String subject, String body) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");

    if (!TextUtils.isEmpty(to)) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
    }/*from  w  w w  . j  a v  a  2  s .  c  om*/
    if (!TextUtils.isEmpty(subject)) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }
    if (!TextUtils.isEmpty(body)) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    final PackageManager pm = (PackageManager) context.getPackageManager();
    try {
        if (pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
            intent.setType("text/plain");
        }
    } catch (Exception e) {
        Log.w("Exception encountered while looking for email intent receiver.", e);
    }

    context.startActivity(intent);
}

From source file:com.github.akinaru.bleremote.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object// w w  w. ja  va 2 s  . c  om
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context,
        IRemoteActivity remoteActivity) {

    switch (menuItem.getItemId()) {
    case R.id.disconnect_device: {
        if (remoteActivity != null) {
            remoteActivity.disconnect();
        }
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", context.getResources().getString(R.string.email_addr), null));
        intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_subject));
        intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.report_hint));
        context.startActivity(
                Intent.createChooser(intent, context.getResources().getString(R.string.issue_title)));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog(context);
        d.show();
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:com.btmura.android.reddit.app.MenuHelper.java

public static void share(Context context, CharSequence subject, CharSequence text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    Contexts.startActivity(context, makeChooser(context, intent, R.string.menu_share));
}

From source file:com.manning.androidhacks.hack004.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);

    Preference sharePref = findPreference("pref_share");
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Check this app!");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Check this awesome app at: ...");
    sharePref.setIntent(shareIntent);//from  w  ww .jav  a  2 s . c o m

    Preference ratePref = findPreference("pref_rate");
    Uri uri = Uri.parse("market://details?id=" + getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    ratePref.setIntent(goToMarket);

    updateUserText();
}

From source file:ca.mudar.snoozy.ui.activity.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == android.R.id.home) {
        // Respond to the action bar's Up/Home button
        NavUtils.navigateUpFromSameTask(this);
        return true;
    } else if (item.getItemId() == R.id.action_settings) {
        Intent intent = new Intent(this, SettingsActivity.class);
        startActivity(intent);/*from   ww  w  . j a  v a2s  .  c o m*/
        return true;
    } else if (item.getItemId() == R.id.action_about) {
        Intent intent = new Intent(this, AboutActivity.class);
        startActivity(intent);
        return true;
    } else if (item.getItemId() == R.id.action_eula) {
        Intent intent = new Intent(this, EulaActivity.class);
        startActivity(intent);
        return true;
    } else if (item.getItemId() == R.id.action_share) {
        /*
         Native sharing
          */
        final Bundle extras = new Bundle();
        extras.putString(Intent.EXTRA_SUBJECT, getResources().getString(R.string.share_intent_title));
        extras.putString(Intent.EXTRA_TEXT, Const.URL_PLAYSTORE);

        final Intent sendIntent = new Intent();
        sendIntent.putExtras(extras);
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.setType(this.SEND_INTENT_TYPE);
        startActivity(sendIntent);
    } else if (item.getItemId() == R.id.action_rate) {
        /*
         Launch Playstore to rate app
          */
        final Intent viewIntent = new Intent(Intent.ACTION_VIEW);
        viewIntent.setData(Uri.parse(Const.URL_PLAYSTORE));
        startActivity(viewIntent);
    }

    return super.onOptionsItemSelected(item);
}