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:com.zhongyun.viewer.cameralist.CameraListActivity.java

@Override
public void onClick(View v) {
    int id = v.getId();
    switch (id) {
    case R.id.help:
        Intent guideIntent = new Intent();
        guideIntent.setClass(getApplicationContext(), GuideActivity.class);
        guideIntent.putExtra(GuideActivity.START_AVS_ACTIVITY, false);
        startActivity(guideIntent);//from   ww  w. j  a  v a2s. c o  m
        break;
    case R.id.feedback:
        FeedbackAgent agent = new FeedbackAgent(this);
        agent.startFeedbackActivity();
        break;
    case R.id.about:
        showAboutDialog();
        break;
    case R.id.disclaimer:
        showDisclaimerDlg();
        break;
    case R.id.business:
        try {
            Intent data = new Intent(Intent.ACTION_SENDTO);
            data.setData(Uri.parse("mailto:business@ichano.com"));
            startActivity(data);
        } catch (Exception e) {
            Toast.makeText(getApplicationContext(), R.string.mail_to, Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.logout:
        mUserInfo.setLoginInfo(false, "", "", "");
        Intent intent = new Intent();
        intent.setClass(getApplicationContext(), LoginActivity.class);
        startActivity(intent);
        isExitWithLogout = true;
        mMyViewerHelper.removeAllCameraInfos();
        mCameraInfoManager.deleteAll();
        finish();
        break;
    case R.id.back_linlayout:
        if (!mUserLayout.isDrawerOpen(Gravity.LEFT))
            mUserLayout.openDrawer(Gravity.LEFT);
        break;
    case R.id.opt_linlayout:
        openAddDialog();
        break;
    case R.id.add_cid:
        if (mShowAddLayoutDialog != null) {
            mShowAddLayoutDialog.dismiss();
            titlebar_opt_image.setBackgroundResource(R.drawable.add_icon);
        }
        showAddCameraDlg();
        break;
    case R.id.add_cid_by_qr:
        if (mShowAddLayoutDialog != null) {
            mShowAddLayoutDialog.dismiss();
            titlebar_opt_image.setBackgroundResource(R.drawable.add_icon);
        }
        Intent intent1 = new Intent();
        intent1.setClass(this, CaptureActivity.class);
        intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivityForResult(intent1, SCANNIN_GREQUEST_CODE);
        break;
    default:
        break;
    }
}

From source file:com.android.contacts.common.list.ShortcutIntentBuilder.java

private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData,
        String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) {
    Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);

    Bitmap bitmap;/*from  ww w  .ja v  a2  s .c o  m*/
    Uri phoneUri;
    if (Intent.ACTION_CALL.equals(shortcutAction)) {
        // Make the URI a direct tel: URI so that it will always continue to work
        phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call);
    } else {
        phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp);
    }

    Intent shortcutIntent = new Intent(shortcutAction, phoneUri);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    Intent intent = new Intent();
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);

    if (TextUtils.isEmpty(displayName)) {
        displayName = mContext.getResources().getString(R.string.missing_name);
    }
    if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.call_by_shortcut, displayName));
    } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.sms_by_shortcut, displayName));
    }

    mListener.onShortcutIntentCreated(uri, intent);
}

From source file:com.xabber.android.ui.activity.ContactList.java

@Override
protected void onResume() {
    super.onResume();
    barPainter.setDefaultColor();/*  www.  jav a  2s .  c  o  m*/
    rebuildAccountToggle();
    Application.getInstance().addUIListener(OnAccountChangedListener.class, this);

    if (action != null) {
        switch (action) {
        case ContactList.ACTION_ROOM_INVITE:
        case Intent.ACTION_SEND:
        case Intent.ACTION_CREATE_SHORTCUT:
            if (Intent.ACTION_SEND.equals(action)) {
                sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
            }
            Toast.makeText(this, getString(R.string.select_contact), Toast.LENGTH_LONG).show();
            break;
        case Intent.ACTION_VIEW: {
            action = null;
            Uri data = getIntent().getData();
            if (data != null && "xmpp".equals(data.getScheme())) {
                XMPPUri xmppUri;
                try {
                    xmppUri = XMPPUri.parse(data);
                } catch (IllegalArgumentException e) {
                    xmppUri = null;
                }
                if (xmppUri != null && "message".equals(xmppUri.getQueryType())) {
                    ArrayList<String> texts = xmppUri.getValues("body");
                    String text = null;
                    if (texts != null && !texts.isEmpty()) {
                        text = texts.get(0);
                    }
                    openChat(xmppUri.getPath(), text);
                }
            }
            break;
        }
        case Intent.ACTION_SENDTO: {
            action = null;
            Uri data = getIntent().getData();
            if (data != null) {
                String path = data.getPath();
                if (path != null && path.startsWith("/")) {
                    openChat(path.substring(1), null);
                }
            }
            break;
        }

        case ContactList.ACTION_MUC_PRIVATE_CHAT_INVITE:
            action = null;
            showMucPrivateChatDialog();
            break;

        case ContactList.ACTION_CONTACT_SUBSCRIPTION:
            action = null;
            showContactSubscriptionDialog();
            break;

        case ContactList.ACTION_INCOMING_MUC_INVITE:
            action = null;
            showMucInviteDialog();
            break;

        }
    }

    if (Application.getInstance().doNotify()) {
        if (!SettingsManager.isTranslationSuggested()) {
            Locale currentLocale = getResources().getConfiguration().locale;
            if (!currentLocale.getLanguage().equals("en") && !getResources().getBoolean(R.bool.is_translated)) {
                new TranslationDialog().show(getFragmentManager(), "TRANSLATION_DIALOG");
                SettingsManager.setTranslationSuggested();
            }
        }

        if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot()
                && !SettingsManager.startAtBootSuggested()) {
            StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT");
        }

        if (SettingsManager.interfaceTheme() != SettingsManager.InterfaceTheme.dark) {
            if (!SettingsManager.isDarkThemeSuggested() && SettingsManager.bootCount() > 0) {
                new DarkThemeIntroduceDialog().show(getFragmentManager(),
                        DarkThemeIntroduceDialog.class.getSimpleName());
                SettingsManager.setDarkThemeSuggested();
            }
        } else {
            SettingsManager.setDarkThemeSuggested();
        }

        if (!SettingsManager.contactIntegrationSuggested() && Application.getInstance().isContactsSupported()) {
            if (AccountManager.getInstance().getAllAccounts().isEmpty()) {
                SettingsManager.setContactIntegrationSuggested();
            } else {
                ContactIntegrationDialogFragment.newInstance().show(getFragmentManager(),
                        "CONTACT_INTEGRATION");
            }
        }
    }
}

From source file:com.mobileglobe.android.customdialer.common.list.ShortcutIntentBuilder.java

private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData,
        String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) {
    Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);

    Bitmap bitmap;/*ww  w  . j  a v  a2s  . co  m*/
    Uri phoneUri;
    if (Intent.ACTION_CALL.equals(shortcutAction)) {
        // Make the URI a direct tel: URI so that it will always continue to work
        phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call);
    } else {
        phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp_mirrored);
    }

    Intent shortcutIntent = new Intent(shortcutAction, phoneUri);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    Intent intent = new Intent();
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);

    if (TextUtils.isEmpty(displayName)) {
        displayName = mContext.getResources().getString(R.string.missing_name);
    }
    if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.call_by_shortcut, displayName));
    } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.sms_by_shortcut, displayName));
    }

    mListener.onShortcutIntentCreated(uri, intent);
}

From source file:com.denel.facepatrol.MainActivity.java

public void ContactEdit(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Contact Information Feedback")
            .setMessage("You're about to edit and send personal information. "
                    + "Please note that the current database will only reflect your modification"
                    + " once the IT department verifies the change and the updated database"
                    + " is synced to your device. \n \n Do you want to continue?")
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
                    emailIntent.setData(Uri.parse("mailto:"));
                    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "pkantue@gmail.com" }); // this email address will change
                    emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, feedback_subject);
                    emailIntent.putExtra(Intent.EXTRA_TEXT, feedback_body);
                    startActivity(Intent.createChooser(emailIntent, "Send Email..."));
                }/*from ww  w .j  a va 2s . com*/
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // User cancelled the dialog 
                }
            });
    builder.show();
    // exit the application
    //finish();      
}

From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventsListActivity.java

private void ProcessDrawerClick(int position) {
    switch (position) {
    case SETTINGS: {
        try {//w  w  w  .ja  v  a  2  s . c  o m
            Intent SettingsIntent = new Intent(ViewZenossEventsListActivity.this, SettingsFragment.class);
            this.startActivityForResult(SettingsIntent, 99);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "ProcessDrawerClick settings",
                    e);
        }

    }
        break;

    case CONFIGURERHYBUDDPUSH: {
        try {
            Intent PushSettingsIntent = new Intent(ViewZenossEventsListActivity.this, PushConfigActivity.class);
            this.startActivityForResult(PushSettingsIntent, ZenossAPI.ACTIVITYRESULT_PUSHCONFIG);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                    "ProcessDrawerClick CONFIGURERHYBUDDPUSH", e);
        }
    }
        break;

    case HELP: {
        try {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("http://wiki.zenoss.org/Android"));
            startActivity(i);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "ProcessDrawerClick HELP", e);
        }

    }
        break;

    case INFRASTRUCTURE: {
        try {
            Intent DeviceList = new Intent(ViewZenossEventsListActivity.this,
                    ViewZenossDeviceListActivity.class);
            ViewZenossEventsListActivity.this.startActivity(DeviceList);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                    "ProcessDrawerClick INFRASTRUCTURE", e);
        }
    }
        break;

    case GROUPS: {
        try {
            Intent GroupsIntent = new Intent(ViewZenossEventsListActivity.this, ViewZenossGroupsActivity.class);
            ViewZenossEventsListActivity.this.startActivity(GroupsIntent);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "ProcessDrawerClick GROUPS",
                    e);
        }
    }
        break;

    case MANAGEDATABASE: {
        try {
            Intent MangeDBIntent = new Intent(ViewZenossEventsListActivity.this, ManageDatabase.class);
            ViewZenossEventsListActivity.this.startActivity(MangeDBIntent);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                    "ProcessDrawerClick MANAGEDATABASE", e);
        }
    }
        break;

    case FEEDBACK: {
        try {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "Gareth@DataSift.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback suggestion for Rhybudd");
            startActivity(Intent.createChooser(emailIntent, "Send feedback as email"));
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "ProcessDrawerClick FEEDBACK",
                    e);

            try {
                Toast.makeText(ViewZenossEventsListActivity.this,
                        "There was a problem launching your email client.\n\nPlease email Gareth@DataSift.com with your feedback.",
                        Toast.LENGTH_LONG).show();
            } catch (Exception e1) {
                BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                        "ProcessDrawerClick FEEDBACK Toast", e1);
            }

        }
    }
        break;

    case SEARCH: {
        try {
            onSearchRequested();
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "ProcessDrawerClick SEARCH",
                    e);
        }
    }
        break;

    case DIAGNOSTIC: {
        try {
            Intent DiagIntent = new Intent(ViewZenossEventsListActivity.this, DiagnosticActivity.class);
            ViewZenossEventsListActivity.this.startActivity(DiagIntent);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                    "ProcessDrawerClick DIAGNOSTIC", e);
        }
    }
        break;
    }

    // update selected item and title, then close the drawer
    try {
        mDrawerList.setItemChecked(position, false);
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                "ProcessDrawerClick setitemchecked false", e);
    }

    try {
        mDrawerLayout.closeDrawer(mDrawerList);
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "ProcessDrawerClick closeDrawer",
                e);
    }
}

From source file:com.silentcircle.contacts.calllognew.CallLogAdapter.java

private void startActivityForAction(View view) {
    final IntentProvider intentProvider = (IntentProvider) view.getTag();
    if (intentProvider != null) {
        final Intent intent = intentProvider.getIntent(mContext);
        // See IntentProvider.getCallDetailIntentProvider() for why this may be null.
        if (intent == null)
            return;
        // Intent to show call log details has no action, send also if we cannot handle call directly
        if (intent.getAction() == null || mPhoneNumberPickerActionListener == null) {
            DialerUtils.startActivityWithErrorToast(mContext, intent);
            return;
        }//from   w  w w  .  j a  va 2s .  c  o m
        if (Intent.ACTION_SENDTO.equals(intent.getAction())) {
            view.getContext().startActivity(intent);
            return;
        }
        Uri numberUri = intent.getData();
        String number = numberUri.getSchemeSpecificPart();
        mPhoneNumberPickerActionListener.onCallNumberDirectly(number);
    }
}

From source file:com.silentcircle.silenttext.util.DeviceUtils.java

public static Intent getShareDebugInformationIntent(Context context) {

    Intent intent = new Intent(Intent.ACTION_SENDTO,
            Uri.fromParts("mailto", context.getString(R.string.support_email_address), null));

    intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.support_email_subject));
    intent.putExtra(Intent.EXTRA_TEXT, wrap(LABEL_DEBUG_INFO, getDebugInformation(context)));

    ResolveInfo info = context.getPackageManager().resolveActivity(intent, 0);

    if (info == null) {
        intent.setAction(Intent.ACTION_SEND);
        intent.setDataAndType(null, "text/plain");
    }/*from  w ww  .  ja  v  a  2  s.c om*/

    return Intent.createChooser(intent,
            context.getString(R.string.share_with, context.getString(R.string.feedback)));

}

From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java

/**
 * If email apps are available.//from   w ww .ja  va2  s  .co m
 *
 * @param ctx
 * The application context.
 * @return
 * true if available, otherwise false
 */
private boolean isEmailAccountConfigured(Context ctx) {
    Uri uri = Uri.fromParts("mailto", "max@mustermann.com", null);
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    PackageManager pm = ctx.getPackageManager();
    int apps = pm.queryIntentActivities(intent, 0).size();

    if (apps == 0) {
        return false;
    }

    AccountManager am = AccountManager.get(ctx);
    int accounts;

    try {
        accounts = am.getAccounts().length;
    } catch (Exception e) {
        Log.e("EmailComposer", "Missing GET_ACCOUNTS permission.");
        return true;
    }

    return accounts > 0;
}

From source file:com.xabber.android.ui.activity.ContactListActivity.java

@Override
protected void onResume() {
    super.onResume();

    if (!AccountManager.getInstance().hasAccounts()) {
        startActivity(IntroActivity.createIntent(this));
        finish();// w ww .j a  va 2  s.  c om
        return;
    }

    barPainter.setDefaultColor();
    rebuildAccountToggle();
    Application.getInstance().addUIListener(OnAccountChangedListener.class, this);

    if (action != null) {
        switch (action) {
        case ContactListActivity.ACTION_ROOM_INVITE:
        case Intent.ACTION_SEND:
        case Intent.ACTION_CREATE_SHORTCUT:
            if (Intent.ACTION_SEND.equals(action)) {
                sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
            }
            Toast.makeText(this, getString(R.string.select_contact), Toast.LENGTH_LONG).show();
            break;
        case Intent.ACTION_VIEW: {
            action = null;
            Uri data = getIntent().getData();
            if (data != null && "xmpp".equals(data.getScheme())) {
                XMPPUri xmppUri;
                try {
                    xmppUri = XMPPUri.parse(data);
                } catch (IllegalArgumentException e) {
                    xmppUri = null;
                }
                if (xmppUri != null && "message".equals(xmppUri.getQueryType())) {
                    ArrayList<String> texts = xmppUri.getValues("body");
                    String text = null;
                    if (texts != null && !texts.isEmpty()) {
                        text = texts.get(0);
                    }

                    UserJid user = null;
                    try {
                        user = UserJid.from(xmppUri.getPath());
                    } catch (UserJid.UserJidCreateException e) {
                        LogManager.exception(this, e);
                    }

                    if (user != null) {
                        openChat(user, text);
                    }
                }
            }
            break;
        }
        case Intent.ACTION_SENDTO: {
            action = null;
            Uri data = getIntent().getData();
            if (data != null) {
                String path = data.getPath();
                if (path != null && path.startsWith("/")) {
                    try {
                        UserJid user = UserJid.from(path.substring(1));
                        openChat(user, null);
                    } catch (UserJid.UserJidCreateException e) {
                        LogManager.exception(this, e);
                    }
                }
            }
            break;
        }

        case ContactListActivity.ACTION_MUC_PRIVATE_CHAT_INVITE:
            action = null;
            showMucPrivateChatDialog();
            break;

        case ContactListActivity.ACTION_CONTACT_SUBSCRIPTION:
            action = null;
            showContactSubscriptionDialog();
            break;

        case ContactListActivity.ACTION_INCOMING_MUC_INVITE:
            action = null;
            showMucInviteDialog();
            break;

        }
    }

    if (Application.getInstance().doNotify()) {
        if (BatteryHelper.isOptimizingBattery() && !SettingsManager.isBatteryOptimizationDisableSuggested()) {
            BatteryOptimizationDisableDialog.newInstance().show(getFragmentManager(),
                    BatteryOptimizationDisableDialog.class.getSimpleName());
        }

        if (!SettingsManager.isTranslationSuggested()) {
            Locale currentLocale = getResources().getConfiguration().locale;
            if (!currentLocale.getLanguage().equals("en") && !getResources().getBoolean(R.bool.is_translated)) {
                new TranslationDialog().show(getFragmentManager(), "TRANSLATION_DIALOG");
            }
        }

        if (SettingsManager.isCrashReportsSupported() && !SettingsManager.isCrashReportsDialogShown()) {
            CrashReportDialog.newInstance().show(getFragmentManager(), CrashReportDialog.class.getSimpleName());
        }

        if (SettingsManager.interfaceTheme() != SettingsManager.InterfaceTheme.dark) {
            if (!SettingsManager.isDarkThemeSuggested() && SettingsManager.bootCount() > 1) {
                new DarkThemeIntroduceDialog().show(getFragmentManager(),
                        DarkThemeIntroduceDialog.class.getSimpleName());
            }
        } else {
            SettingsManager.setDarkThemeSuggested();
        }

        if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot()
                && !SettingsManager.startAtBootSuggested()) {
            StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT");
        }
    }
}