Example usage for android.content Intent ACTION_SENDTO

List of usage examples for android.content Intent ACTION_SENDTO

Introduction

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

Prototype

String ACTION_SENDTO

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

Click Source Link

Document

Activity Action: Send a message to someone specified by the data.

Usage

From source file:fr.bmartel.android.iotf.app.BaseActivity.java

/**
 * process menu item selected/*from ww  w  . j  a v a  2  s .  c om*/
 *
 * @param menuItem
 * @param mDrawer
 * @param context
 */
protected void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context) {

    switch (menuItem.getItemId()) {
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "kiruazoldik92@gmail.com", null));
        intent.putExtra(Intent.EXTRA_SUBJECT, "iotf Issue");
        intent.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
        context.startActivity(Intent.createChooser(intent, "Report a problem"));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog();
        android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
        d.show(manager, "open_source_components");
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:io.nuclei.cyto.share.PackageTargetManager.java

/**
 * Create an intent without knowing which package has been chosen
 *///from  w ww.  ja v  a2s .com
public Intent onCreateIntent(Context context, String authority) {
    Intent intent = new Intent(TextUtils.isEmpty(mEmail) ? Intent.ACTION_SEND : Intent.ACTION_SENDTO);
    onSetDefault(context, null, authority, intent, mText);
    return intent;
}

From source file:id.satusatudua.sigap.ui.AddTrustedUserActivity.java

@Override
public void onNotFoundUser(String email) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).setIcon(R.mipmap.ic_launcher)
            .setTitle("Email Tidak Terdaftar")
            .setMessage("Email yang anda masukan tidak terdaftar, undang teman anda untuk bergabung ke Sigap?")
            .setPositiveButton("YA, Undang Dia", (dialog, which) -> {
                Intent intent = new Intent(Intent.ACTION_SENDTO);
                intent.setData(Uri.parse("mailto:" + email));
                intent.putExtra(Intent.EXTRA_SUBJECT, "Saya Mengundang Anda Bergabung Ke Sigap");
                intent.putExtra(Intent.EXTRA_TEXT,
                        "Halo...!\nSaya membutuhkan anda untuk menjadi kontak yang saya percayai di Sigap, mari bergabung bersama saya di Sigap untuk mewujudkan kehidupan yang lebih Siap dan Tanggap terhadap segala ancaman bahaya. Untuk bergabung ke Sigap silahkan download aplikasinya di url ini [URL].\nTerimakasih banyak atas perhatiannya.\n\nSalam,\n"
                                + CacheManager.pluck().getCurrentUser().getName());
                startActivity(intent);// ww  w. j  av a2 s  .  c o m
            }).setNegativeButton("TIDAK", (dialog, which1) -> {
                dialog.dismiss();
            }).show();

    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE)
            .setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));
    alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
            .setTextColor(ContextCompat.getColor(this, R.color.primary_text));
    alertDialog.show();
}

From source file:com.artemchep.horario.ui.fragments.details.TeacherDetailsFragment.java

@Override
protected ViewGroup onCreateContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
        @NonNull List<ContentItem<Teacher>> contentItems, @Nullable Bundle savedInstanceState) {
    getToolbar().inflateMenu(R.menu.details_teacher);

    ViewGroup vg = (ViewGroup) inflater.inflate(R.layout.fragment_details_teacher, container, false);
    initWithFab(R.id.action_edit, R.drawable.ic_pencil_white_24dp);

    mNoteContainer = vg.findViewById(R.id.info_container);
    mPhoneContainer = vg.findViewById(R.id.phone_container);
    mPhoneContainer.setOnClickListener(new View.OnClickListener() {
        @Override//from   w  w w  .j a va  2s  .c  o  m
        public void onClick(View view) {
            if (TextUtils.isEmpty(mModel.phone)) {
                Timber.tag(TAG).w("Tried to copy an empty phone!");
                return;
            }
            // Copy email to clipboard
            ClipboardManager clipboard = (ClipboardManager) getContext()
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(mModel.phone, mModel.phone); // TODO: More informative description of the clip
            clipboard.setPrimaryClip(clip);

            // Show toast message
            String msg = getString(R.string.details_phone_clipboard, mModel.phone);
            Toasty.info(getContext(), msg).show();
        }
    });
    mEmailContainer = vg.findViewById(R.id.email_container);
    mEmailContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (TextUtils.isEmpty(mModel.email)) {
                Timber.tag(TAG).w("Tried to copy an empty email!");
                return;
            }
            // Copy email to clipboard
            ClipboardManager clipboard = (ClipboardManager) getContext()
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(mModel.email, mModel.email); // TODO: More informative description of the clip
            clipboard.setPrimaryClip(clip);

            // Show toast message
            String msg = getString(R.string.details_email_clipboard, mModel.email);
            Toasty.info(getContext(), msg).show();
        }
    });
    mPhoneButton = (Button) mPhoneContainer.findViewById(R.id.phone_send);
    mPhoneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (TextUtils.isEmpty(mModel.phone)) {
                Timber.tag(TAG).w("Tried to call an empty phone!");
                return;
            }

            Intent intent = new Intent(Intent.ACTION_DIAL);
            intent.setData(Uri.parse("tel:" + mModel.phone));

            try {
                startActivity(intent);
            } catch (ActivityNotFoundException ignored) {
            }
        }
    });
    mEmailButton = (Button) mEmailContainer.findViewById(R.id.email_send);
    mEmailButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (TextUtils.isEmpty(mModel.email)) {
                Timber.tag(TAG).w("Tried to send to an empty email!");
                return;
            }

            String[] recipients = { mModel.email };
            Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients);
            intent.setAction(Intent.ACTION_SENDTO);
            intent.setData(Uri.parse("mailto:")); // only email apps should handle it

            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
                // TODO:!!!!!
                String msg = "No email app"; //getString(R.string.feedback_error_no_app);
                Toasty.info(getContext(), msg).show();
            }
        }
    });

    mNoteTextView = (TextView) mNoteContainer.findViewById(R.id.info);
    mEmailTextView = (TextView) mEmailContainer.findViewById(R.id.email);
    mPhoneTextView = (TextView) mPhoneContainer.findViewById(R.id.phone);

    // Note
    contentItems.add(new ContentItem<Teacher>() {
        @Override
        public void onSet(@Nullable Teacher model) {
            if (model == null || TextUtils.isEmpty(model.info)) {
                mNoteContainer.setVisibility(View.GONE);
            } else {
                mNoteContainer.setVisibility(View.VISIBLE);
                mNoteTextView.setText(model.info);
            }
        }

        @Override
        public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) {
            String a = old != null ? old.info : null;
            String b = model != null ? model.info : null;
            return !TextUtils.equals(a, b);
        }
    });
    // Email
    contentItems.add(new ContentItem<Teacher>() {
        @Override
        public void onSet(@Nullable Teacher model) {
            if (model == null || TextUtils.isEmpty(model.email)) {
                mEmailContainer.setVisibility(View.GONE);
            } else {
                mEmailContainer.setVisibility(View.VISIBLE);
                mEmailTextView.setText(model.info);

                if (PatternUtils.isEmail(model.email)) {
                    mEmailButton.setVisibility(View.VISIBLE);
                } else
                    mEmailButton.setVisibility(View.GONE);
            }
        }

        @Override
        public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) {
            String a = old != null ? old.email : null;
            String b = model != null ? model.email : null;
            return !TextUtils.equals(a, b);
        }
    });
    // Phone
    contentItems.add(new ContentItem<Teacher>() {
        @Override
        public void onSet(@Nullable Teacher model) {
            if (model == null || TextUtils.isEmpty(model.phone)) {
                mPhoneContainer.setVisibility(View.GONE);
            } else {
                mPhoneContainer.setVisibility(View.VISIBLE);
                mPhoneTextView.setText(model.phone);

                if (PatternUtils.isPhone(model.phone)) {
                    mPhoneButton.setVisibility(View.VISIBLE);
                } else
                    mPhoneButton.setVisibility(View.GONE);
            }
        }

        @Override
        public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) {
            String a = old != null ? old.phone : null;
            String b = model != null ? model.phone : null;
            return !TextUtils.equals(a, b);
        }
    });

    return vg;
}

From source file:de.appplant.cordova.plugin.emailcomposer.EmailComposer.java

/**
 * Gibt an, ob es eine Anwendung gibt, welche E-Mails versenden kann.
 */// w  w  w .  ja  v  a2s  . co  m
private Boolean isEmailAccountConfigured() {
    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "max@mustermann.com", null));
    Boolean available = cordova.getActivity().getPackageManager().queryIntentActivities(intent, 0).size() > 1;

    return available;
}

From source file:com.geecko.QuickLyric.fragment.SettingsFragment.java

@Override
public boolean onPreferenceClick(Preference preference) {
    AlertDialog.Builder dialog;//  w  w w  .  j  a  v  a 2s. co m
    switch (preference.getKey()) {
    case "pref_about":
        dialog = new AlertDialog.Builder(getActivity());
        dialog.setView(
                getActivity().getLayoutInflater().inflate(R.layout.about_dialog, (ViewGroup) getView(), false));
        dialog.create().show();
        break;
    case "pref_contribute":
        Intent browserIntent = new Intent(Intent.ACTION_VIEW);
        browserIntent.setData(Uri.parse("https://github.com/geecko86/QuickLyric"));
        if (browserIntent.resolveActivity(getActivity().getPackageManager()) != null)
            startActivity(browserIntent);
        break;
    case "pref_beta":
        dialog = new AlertDialog.Builder(getActivity());
        dialog.setView(
                getActivity().getLayoutInflater().inflate(R.layout.beta_dialog, (ViewGroup) getView(), false));
        dialog.create().show();
        break;
    case "pref_issues":
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
        emailIntent.setData(Uri.parse("mailto:"));
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "quicklyricapp@gmail.com" });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Issues with QuickLyric");
        if (emailIntent.resolveActivity(getActivity().getPackageManager()) != null)
            startActivity(emailIntent);
        break;
    }
    return true;
}

From source file:io.github.hidroh.materialistic.AppUtils.java

public static Intent makeEmailIntent(String subject, String text) {
    final Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    return intent;
}

From source file:com.android.contacts.common.ContactsUtils.java

/**
 * Returns the proper Intent for an ImDatItem. If available, a secondary intent is stored
 * in the second Pair slot/*ww  w .  j  av  a2s .co m*/
 */
public static Pair<Intent, Intent> buildImIntent(Context context, ImDataItem im) {
    Intent intent = null;
    Intent secondaryIntent = null;
    final boolean isEmail = im.isCreatedFromEmail();

    if (!isEmail && !im.isProtocolValid()) {
        return new Pair<>(null, null);
    }

    final String data = im.getData();
    if (TextUtils.isEmpty(data)) {
        return new Pair<>(null, null);
    }

    final int protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK : im.getProtocol();

    if (protocol == Im.PROTOCOL_GOOGLE_TALK) {
        final int chatCapability = im.getChatCapability();
        if ((chatCapability & Im.CAPABILITY_HAS_CAMERA) != 0) {
            intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?message"));
            secondaryIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?call"));
        } else if ((chatCapability & Im.CAPABILITY_HAS_VOICE) != 0) {
            // Allow Talking and Texting
            intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?message"));
            secondaryIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?call"));
        } else {
            intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?message"));
        }
    } else {
        // Build an IM Intent
        intent = getCustomImIntent(im, protocol);
    }
    return new Pair<>(intent, secondaryIntent);
}

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

/**
 * Constructs an SMS Intent for the given message details and opens the application chooser for this Intent
 *
 * @param recipient the recipient's phone number or `null`
 * @param body the body of the message//from   w w  w .  j  a  v a2  s. c o m
 * @param captionRes the string resource ID for the application chooser's window title
 * @param context the Context instance to start the Intent from
 * @throws Exception if there was an error trying to launch the SMS Intent
 */
public static void sendSMS(final String recipient, final String body, final int captionRes,
        final Context context) throws Exception {
    final Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType(HTTP.PLAIN_TEXT_TYPE);
    if (recipient != null && recipient.length() > 0) {
        intent.setData(Uri.parse("smsto:" + recipient));
    } else {
        intent.setData(Uri.parse("sms:"));
    }
    intent.putExtra("sms_body", body);
    intent.putExtra(Intent.EXTRA_TEXT, body);
    if (context != null) {
        // offer a selection of all applications that can handle the SMS Intent
        context.startActivity(Intent.createChooser(intent, context.getString(captionRes)));
    }
}

From source file:org.chaos.fx.cnbeta.preferences.PreferencesFragment.java

private void composeEmail(String address, String subject) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, "\n\n\n\nApp Version" + BuildConfig.VERSION_NAME
            + "\nAndroid Version: " + Build.VERSION.RELEASE + "\nDevice Model: " + Build.MODEL);
    if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
        startActivity(intent);/*from w  ww.ja  v  a 2s .co m*/
    }
}