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:com.gh4a.CommitActivity.java

@Override
public boolean setMenuOptionItemSelected(MenuItem item) {
    String diffUrl = "https://github.com/" + mRepoOwner + "/" + mRepoName + "/commit/" + mObjectSha;
    switch (item.getItemId()) {
    case android.R.id.home:
        getApplicationContext().openRepositoryInfoActivity(this, mRepoOwner, mRepoName,
                Intent.FLAG_ACTIVITY_CLEAR_TOP);
        return true;
    case R.id.browser:
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(diffUrl));
        startActivity(browserIntent);//from  w  ww .j a  v  a2 s .c  o m
        return true;
    case R.id.share:
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_SUBJECT,
                "Commit #" + mObjectSha.substring(0, 7) + " at " + mRepoOwner + "/" + mRepoName);
        shareIntent.putExtra(Intent.EXTRA_TEXT, "Commit #" + mObjectSha.substring(0, 7) + " at " + mRepoOwner
                + "/" + mRepoName + " " + diffUrl);
        shareIntent = Intent.createChooser(shareIntent, "Share");
        startActivity(shareIntent);
        return true;
    default:
        return true;
    }
}

From source file:com.crowflying.buildwatch.ConfigurationActivity.java

@Override
public boolean onPreferenceClick(Preference preference) {
    Log.d(LOG_TAG, String.format("Preference %s was clicked...", preference.getKey()));
    // Call the code for autosetup...
    if (PREFS_AUTOSETUP.equals(preference.getKey())) {
        Log.i(LOG_TAG, "Calling XZING.");
        tracker.trackEvent("configuration", "subscreen", "autosetup", 0L);

        IntentIntegrator integrator = new IntentIntegrator(this);
        integrator.setMessageByID(R.string.barcode_scanner_not_installed_message);
        integrator.initiateScan();//from  ww  w.  j  ava  2  s. co m
        return true;
    }
    if (PREFS_FORGET_SETTINGS.equals(preference.getKey())) {
        Log.i(LOG_TAG, "Forgetting all settings");
        tracker.trackEvent("configuration", "action", "settings_cleared", 0L);
        PreferenceManager.getDefaultSharedPreferences(this).edit().clear().commit();
        return true;
    }
    if (PREFS_KEY_LAUNCH_WEBSITE.equals(preference.getKey())) {
        Log.i(LOG_TAG, "Launching website");
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(getString(R.string.config_launch_website_url)));
        startActivity(i);
        return true;
    }
    if (PREFS_KEY_GCM_TOKEN.equals(preference.getKey())) {
        String token = getPreferenceManager().getSharedPreferences().getString(PREFS_KEY_GCM_TOKEN, "");
        if (!TextUtils.isEmpty(token)) {
            Log.i(LOG_TAG, "Token clicked. Echoing it to the logfile for convencience: " + token);
            Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    getString(R.string.share_gcm_token_subject));
            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, token);
            startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_gcm_token_using)));
        }
        return true;
    }
    return false;
}

From source file:com.activiti.android.app.fragments.content.ContentsFragment.java

@Subscribe
public void onDownloadTransferEvent(DownloadTransferEvent event) {
    if (event.hasException) {
        Snackbar.make(getActivity().findViewById(R.id.left_panel), event.exception.getMessage(),
                Snackbar.LENGTH_SHORT).show();
        return;//from   ww w . java2s . co  m
    }

    if (waitingDialog != null) {
        waitingDialog.dismiss();
    }

    try {
        switch (event.mode) {
        case ContentTransferSyncAdapter.MODE_SHARE:
            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName());
            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(event.data));
            sendIntent.setType(event.mimetype);
            getActivity().startActivity(
                    Intent.createChooser(sendIntent, getResources().getText(R.string.action_send_file)));
            break;
        case ContentTransferSyncAdapter.MODE_OPEN_IN:
            Intent viewIntent = new Intent(Intent.ACTION_VIEW);
            viewIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName());
            viewIntent.setDataAndType(Uri.fromFile(event.data), event.mimetype);
            startActivity(viewIntent);
            break;
        }
    } catch (ActivityNotFoundException e) {
        Snackbar.make(getActivity().findViewById(R.id.left_panel), R.string.file_editor_error_open,
                Snackbar.LENGTH_SHORT).show();
    }
}

From source file:br.liveo.ndrawer.ui.fragment.FragmentContactus.java

@Override
public void onClick(View view) {

    Log.i("Main Fragment fragment", "on click");
    String tflag = null;/*  ww  w. ja v a 2s .  co m*/

    switch (view.getId()) {

    case R.id.ivemail_dtu:
        Intent i = new Intent(Intent.ACTION_SENDTO);
        i.setData(Uri.parse("mailto:renaissance@dce.edu"));
        i.putExtra(Intent.EXTRA_SUBJECT, "Queries Regarding IET DTU Student Chapter");
        startActivity(i);

        break;
    case R.id.ivemail_mukcha:
        Intent i2 = new Intent(Intent.ACTION_SENDTO);
        i2.setData(Uri.parse("mailto:mukul0505@gmail.com"));
        i2.putExtra(Intent.EXTRA_SUBJECT, "Queries Regarding IET DTU Student Chapter");
        startActivity(i2);

        break;
    case R.id.ivemail_mukkum:
        Intent i3 = new Intent(Intent.ACTION_SENDTO);
        i3.setData(Uri.parse("mailto:mukulcj@gmail.com"));
        i3.putExtra(Intent.EXTRA_SUBJECT, "Queries Regarding IET DTU Student Chapter");
        startActivity(i3);

        break;
    case R.id.ivcall_mukcha:
        Intent i4 = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:9873113748"));
        startActivity(i4);

        break;
    case R.id.ivcall_mukkum:
        Intent i5 = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:9013616477"));
        startActivity(i5);

        break;

    }

}

From source file:com.google.android.demos.jamendo.app.AlbumActivity.java

private void share() {
    long id = ContentUris.parseId(getIntent().getData());
    Uri uri = ContentUris.withAppendedId(BASE_URI, id);
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    Cursor cursor = mHeaderAdapter.getCursor();
    if (cursor != null && cursor.moveToFirst()) {
        String albumName = cursor.getString(cursor.getColumnIndexOrThrow(Albums.NAME));
        String artistName = cursor.getString(cursor.getColumnIndexOrThrow(Artists.NAME));
        String template = getString(R.string.jamendo_template_album_artist);
        String subject = MessageFormat.format(template, albumName, artistName);
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }//from   w  w  w .j  a  v a  2  s  . com
    intent.putExtra(Intent.EXTRA_TEXT, String.valueOf(uri));
    intent = Intent.createChooser(intent, null);
    startActivity(intent);
}

From source file:com.infamous.site.activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.more:
        return true;
    case R.id.shareButton:
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_link));
        startActivity(Intent.createChooser(shareIntent, "Share Via"));
        break;//  w ww  . j a  va2s  .  com
    case R.id.rateButton:
        Intent rate = new Intent(Intent.ACTION_VIEW)
                .setData(Uri.parse(getResources().getString(R.string.market_rate)));
        startActivity(rate);
        break;
    case R.id.emailButton:
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                new String[] { getResources().getString(R.string.email_address) });
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                getResources().getText(R.string.email_subject));
        emailIntent.setType("plain/text");
        startActivity(Intent.createChooser(emailIntent, "Contact Developer"));

        break;
    case R.id.aboutButton:
        Intent about = new Intent(MainActivity.this, AboutDev.class);
        startActivity(about);
        break;
    case R.id.aboutButton2:
        Intent about2 = new Intent(MainActivity.this, AboutDev2.class);
        startActivity(about2);
        break;
    case R.id.gplusButton:
        Intent gpCommunity = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://goo.gl/VrsA4Q"));
        startActivity(gpCommunity);
        break;
    }
    return true;
}

From source file:com.artemchep.horario.ui.dialogs.FeedbackDialog.java

private boolean send(@NonNull CharSequence title, @NonNull CharSequence body) {
    Activity activity = getActivity();/*from   ww w.  j  av  a 2 s  .c o  m*/
    String[] recipients = { Binfo.SUPPORT_EMAIL };
    Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients).putExtra(Intent.EXTRA_SUBJECT, title)
            .putExtra(Intent.EXTRA_TEXT, body);
    intent.setAction(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle it

    try {
        startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        Toasty.error(activity, getString(R.string.feedback_error_no_app), Toast.LENGTH_LONG).show();
        return false;
    }
}

From source file:com.adkdevelopment.earthquakesurvival.ui.InfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.info_fragment, container, false);
    ImageView backdrop = ButterKnife.findById(getActivity(), R.id.backdrop);
    FloatingActionButton floatingActionButton = ButterKnife.findById(getActivity(), R.id.fab);

    mUnbinder = ButterKnife.bind(this, rootView);

    if (getActivity().getIntent() != null) {
        int section = getActivity().getIntent().getIntExtra(SurvivalFragment.SECTION, -1);
        List<String> titles = new ArrayList<>();
        List<String> text = new ArrayList<>();
        String title = "";

        int drawable = -1;

        switch (section) {
        case 1://from   w  w w . j  a  va 2s .c o  m
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_before_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_before_text)));
            drawable = R.drawable.earth1;
            title = getString(R.string.survival_before);
            break;
        case 2:
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_during_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_during_text)));
            drawable = R.drawable.earth2;
            title = getString(R.string.survival_during);
            break;
        case 3:
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_after_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_after_text)));
            drawable = R.drawable.earth3;
            title = getString(R.string.survival_after);
            break;
        case 4:
            title = getString(R.string.survival_resources);
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_resources_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_resources_text)));
            drawable = R.drawable.earth3;
            break;
        case 5:
            title = getString(R.string.survival_kit);
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_kit_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_kit_text)));
            drawable = R.drawable.earth3;
            break;
        default:
            break;
        }

        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL,
                false);
        InfoAdapter mRecentAdapter = new InfoAdapter(titles, text);

        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.setAdapter(mRecentAdapter);

        floatingActionButton.setOnClickListener(click -> {
            if (_rxBus.hasObservers()) {
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/html");
                if (titles.size() > 0 && text.size() > 0) {
                    intent.putExtra(Intent.EXTRA_SUBJECT, titles.get(0));
                    intent.putExtra(Intent.EXTRA_TEXT, text.get(0));
                }
                _rxBus.send(Intent.createChooser(intent, getString(R.string.send_email)));
            }
        });

        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null) {
            actionBar.setTitle(title);
        }

        Picasso.with(getContext()).load(drawable).error(R.drawable.dropcoverholdon).into(backdrop);
    }
    return rootView;
}

From source file:com.darizotas.metadatastrip.FileDetailFragment.java

/**
 * Creates the Share Intent that contains the 
 * @param container Metadata container./*from  w w w.j a v  a2  s  .c o  m*/
 * @return Intent for sharing.
 */
private Intent getShareIntent(MetaDataContainer container) {
    Intent intent = new Intent(Intent.ACTION_SEND);

    intent.putExtra(Intent.EXTRA_SUBJECT, "[" + getResources().getString(R.string.app_name) + "] "
            + getResources().getString(R.string.share_subject) + " " + container.getFileName());
    intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_text) + " "
            + DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()));

    try {
        // http://stackoverflow.com/questions/3272534/what-content-type-value-should-i-send-for-my-xml-sitemap
        // http://www.grauw.nl/blog/entry/489
        intent.setType("application/xml");
        //https://developer.android.com/training/sharing/send.html#send-binary-content
        //https://developer.android.com/reference/android/support/v4/content/FileProvider.html
        mStripFile = getMetadataFile(container);
        Uri uri = FileProvider.getUriForFile(getActivity(), "com.darizotas.metadatastrip", mStripFile);
        intent.putExtra(Intent.EXTRA_STREAM, uri);

    } catch (IllegalArgumentException e) {
        // Invalidates the intent.
        intent.setType(null);
    }
    return intent;
}

From source file:org.teleportr.activity.Autocompletion.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case R.id.about:
        startActivity(new Intent(this, About.class));
        break;//from ww w . j  av a2  s. c o m

    case R.id.refresh:
        new FetchNearbyDownloads().execute("");
        break;

    case R.id.feedback:
        new AlertDialog.Builder(this).setTitle("feedback").setIcon(android.R.drawable.ic_dialog_info)
                .setPositiveButton("send logs", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        LogCollector.feedback(Autocompletion.this, "scotty@teleportr.org, flo@andlabs.de");
                    }
                }).setNeutralButton("mail scotty", new Dialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent = new Intent(Intent.ACTION_SENDTO,
                                Uri.parse("mailto:scotty@teleportr.org, flo@andlabs.de"));
                        intent.putExtra(Intent.EXTRA_SUBJECT, "feedback " + getString(R.string.app_name));
                        try {
                            PackageInfo info = getPackageManager().getPackageInfo("org.teleportr",
                                    PackageManager.GET_META_DATA);
                            intent.putExtra(Intent.EXTRA_TEXT,
                                    "version: " + info.versionName + " (" + info.versionCode + ") \n");
                        } catch (NameNotFoundException e) {
                        }
                        startActivity(intent);
                    }
                }).show();
        break;
    }
    return super.onOptionsItemSelected(item);
}