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:net.sharermax.mword.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about);//www .ja v a  2 s.c om
    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(getApplicationContext());
    //
    mSwipeBackEnable = sharedPreferences.getBoolean(PreferenceKey.SWIPE_BACK_KEY, true);
    mSwipeBackLayout = getSwipeBackLayout();
    if (mSwipeBackEnable) {
        //               Log.v("BASIC", "YYY");
        mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
    } else {
        setSwipeBackEnable(false);
    }

    mImmersionEnable = sharedPreferences.getBoolean(PreferenceKey.IMMERSION_KEY, true);
    if (mImmersionEnable && android.os.Build.VERSION.SDK_INT > 18) {
        Window window = getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

    }

    getActionBar().setDisplayHomeAsUpEnabled(true);
    mlistView = (ListView) findViewById(R.id.about_listview);
    //      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, getData());
    //      listView.setAdapter(adapter);
    //      listView.setText
    SimpleAdapter adapter = new SimpleAdapter(this, getData(), R.layout.about_item,
            new String[] { "text1", "text2" }, new int[] { R.id.text1, R.id.text2 });
    mlistView.setAdapter(adapter);
    mlistView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub

            switch (arg2) {
            case 0:
                //               Log.v("listview", "0");
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://sharermax.net/%E5%85%B3%E4%BA%8E%E6%88%91/"));
                startActivity(intent);
                break;
            case 1:
                //               Log.v("listview", "1");
                Intent intent1 = new Intent(Intent.ACTION_VIEW);
                intent1.setData(Uri.parse("http://git.oschina.net/watermelon/MWord"));
                startActivity(intent1);
                break;
            case 2:
                //               Log.v("listview", "2");
                Intent intent2 = new Intent(Intent.ACTION_VIEW);
                intent2.setData(Uri.parse("http://git.oschina.net/watermelon/MWord/raw/master/LICENSE"));
                startActivity(intent2);
                break;
            case 3:
                break;
            case 4:
                //               Log.v("listview", "4");
                Intent intent4 = new Intent(Intent.ACTION_SENDTO);
                intent4.setData(Uri.parse("mailto:mdcw1103@gmail.com"));
                startActivity(Intent.createChooser(intent4, ""));
                break;
            case 5:
                //               Log.v("listview", "5");
                UpdateApp updateApp = new UpdateApp(AboutActivity.this, UpdateApp.VERSION_TYPE_BETA);
                updateApp.setTaskOverListener(new TaskOverListener() {

                    @Override
                    public void taskOver(int versionCode) {
                        // TODO Auto-generated method stub
                        PackageManager packageManager = AboutActivity.this.getPackageManager();
                        try {
                            PackageInfo packageInfo = packageManager
                                    .getPackageInfo(AboutActivity.this.getPackageName(), 0);
                            //                        Log.v("UPDATE", "" + versionCode);
                            if (versionCode > packageInfo.versionCode) {

                                Toast.makeText(getApplicationContext(), "", Toast.LENGTH_LONG).show();
                                UpdateApp.updateNotification(AboutActivity.this);
                            } else {
                                Toast.makeText(getApplicationContext(), "", Toast.LENGTH_LONG)
                                        .show();
                            }
                        } catch (NameNotFoundException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });
                updateApp.startTask();
                break;
            default:
                break;
            }

        }
    });
}

From source file:org.montanafoodhub.app.producer.ProducerDetailFragment.java

private void onClickContact() {
    if (hasEmail(_producer)) {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.parse("mailto:" + _producer.getContactEmail() + "," + HubInit.getHubEmailTo()));
        intent.putExtra(Intent.EXTRA_SUBJECT, "Hub Request For: " + _producer.getName());
        intent.putExtra(Intent.EXTRA_TEXT, "<grower love here...>");
        ActivityUtils.startImplicitActivity(getActivity(), intent, R.string.no_email_application, LogTag);
    } else {//from ww  w  . ja  v a 2  s.  co m
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + _producer.getContactEmail()));
        ActivityUtils.startImplicitActivity(getActivity(), intent, R.string.no_phone_application, LogTag);
    }
}

From source file:com.ieeecsvit.riviera17android.activity.MainActivity.java

public Intent createEmailOnlyChooserIntent(Intent source, CharSequence chooserTitle) {
    Stack<Intent> intents = new Stack<Intent>();
    Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "tushar.narula17@live.com", null));
    List<ResolveInfo> activities = getPackageManager().queryIntentActivities(i, 0);

    for (ResolveInfo ri : activities) {
        Intent target = new Intent(source);
        target.setPackage(ri.activityInfo.packageName);
        intents.add(target);/*from  w ww  . j a v a 2s.c  om*/
    }

    if (!intents.isEmpty()) {
        Intent chooserIntent = Intent.createChooser(intents.remove(0), chooserTitle);
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intents.toArray(new Parcelable[intents.size()]));

        return chooserIntent;
    } else {
        return Intent.createChooser(source, chooserTitle);
    }
}

From source file:com.davidmiguel.gobees.apiaries.ApiariesActivity.java

/**
 * Opens send feedback option.//from   w w w.j a v  a 2s.  c o m
 */
private void openSendFeedback() {
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
            Uri.parse("mailto:" + getString(R.string.gobees_email)));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.gobees_email_subject));
    emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.gobees_email_body));
    startActivity(Intent.createChooser(emailIntent, getString(R.string.feedback_title)));
}

From source file:com.wowza.gocoder.sdk.sampleapp.InfoActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_share:
        String uriText = "mailto:support@wowza.com" + "?subject="
                + Uri.encode("GoCoder SDK Support Information") + "&body=" + Uri.encode(shareContents());

        Uri uri = Uri.parse(uriText);/*from www .j av  a2 s. c om*/

        Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
        sendIntent.setData(uri);
        startActivity(Intent.createChooser(sendIntent, "Send to Wowza Support"));

        return true;

    case R.id.action_copy:
        ClipboardManager myClipboard;
        myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);

        ClipData myClip;
        myClip = ClipData.newPlainText("text", shareContents());
        myClipboard.setPrimaryClip(myClip);

        Toast.makeText(this, "Copied to clipboard", Toast.LENGTH_SHORT).show();
        return true;

    default:
        return super.onOptionsItemSelected(item);

    }
}

From source file:com.spit.spirit17.Fragments.DevelopersFragment.java

@Nullable
@Override/*from w w w.  j  ava 2 s.  c o  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_developers, container, false);

    email1 = (TextView) view.findViewById(R.id.emailId_tejas);
    email2 = (TextView) view.findViewById(R.id.emailId_shubham);
    email3 = (TextView) view.findViewById(R.id.emailId_adnan);

    g1 = (Button) view.findViewById(R.id.google_tejas);
    g2 = (Button) view.findViewById(R.id.google_shubham);
    g3 = (Button) view.findViewById(R.id.google_adnan);

    l1 = (Button) view.findViewById(R.id.linkedin_tejas);
    l2 = (Button) view.findViewById(R.id.linkedin_shubham);
    l3 = (Button) view.findViewById(R.id.linkedin_adnan);

    image1 = (ImageView) view.findViewById(R.id.pic_tejas);
    image2 = (ImageView) view.findViewById(R.id.pic_shubham);
    image3 = (ImageView) view.findViewById(R.id.pic_adnan);

    /*Add Your Pics Here And Not In Xml*/
    Picasso.with(getActivity()).load(R.drawable.dev_tejas_bhitle).into(image1);
    Picasso.with(getActivity()).load(R.drawable.dev_shubham_mahajan).into(image2);
    Picasso.with(getActivity()).load(R.drawable.dev_adnan_ansari).into(image3);

    View.OnClickListener linkListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri;
            switch (v.getId()) {

            /*Google+ links*/
            case R.id.google_tejas:
                uri = Uri.parse(getResources().getString(R.string.googleplus_tejas));
                break;
            case R.id.google_shubham:
                uri = Uri.parse(getResources().getString(R.string.googleplus_shubham));
                break;
            case R.id.google_adnan:
                uri = Uri.parse(getResources().getString(R.string.googleplus_adnan));
                break;

            /*LInkedin Links*/
            case R.id.linkedin_tejas:
                uri = Uri.parse(getResources().getString(R.string.linkedin_tejas));
                break;
            case R.id.linkedin_shubham:
                uri = Uri.parse(getResources().getString(R.string.linkedin_shubham));
                break;
            case R.id.linkedin_adnan:
                uri = Uri.parse(getResources().getString(R.string.linkedin_adnan));
                break;
            default:
                uri = Uri.parse(getResources().getString(R.string.linkedin_tejas));
            }
            Intent i = new Intent(Intent.ACTION_VIEW, uri);
            try {
                startActivity(i);
            } catch (Exception e) {
                Toast.makeText(getActivity(), "Error Loading Link", Toast.LENGTH_SHORT).show();
            }

        }
    };

    View.OnClickListener emailListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String to = "";
            switch (v.getId()) {
            /*Email Ids*/
            case R.id.emailId_tejas:
                to = getResources().getString(R.string.email_tejas);
                break;
            case R.id.emailId_shubham:
                to = getResources().getString(R.string.email_shubham);
                break;
            case R.id.emailId_adnan:
                to = getResources().getString(R.string.email_adnan);
                break;
            }
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SENDTO);
            intent.setType("text/plain");
            intent.setData(Uri.parse("mailto:" + to));
            intent.putExtra(Intent.EXTRA_EMAIL, to);
            try {
                startActivity(Intent.createChooser(intent, "Send Email"));
            } catch (Exception e) {
                Toast.makeText(getActivity(), e.getStackTrace().toString(), Toast.LENGTH_SHORT).show();
            }
        }
    };
    email1.setOnClickListener(emailListener);
    email2.setOnClickListener(emailListener);
    email3.setOnClickListener(emailListener);
    g1.setOnClickListener(linkListener);
    g2.setOnClickListener(linkListener);
    g3.setOnClickListener(linkListener);
    l1.setOnClickListener(linkListener);
    l2.setOnClickListener(linkListener);
    l3.setOnClickListener(linkListener);

    return view;
}

From source file:com.g11x.checklistapp.ChecklistItemActivity.java

private void createUI() {
    TextView name = (TextView) findViewById(R.id.name);
    name.setText(checklistItem.getName(language));

    TextView description = (TextView) findViewById(R.id.description);
    description.setText(checklistItem.getDescription(language));

    Button getDirections = (Button) findViewById(R.id.directions);
    getDirections.setOnClickListener(new View.OnClickListener() {
        @Override//from w w  w  .j  a  va  2 s .  co  m
        public void onClick(View view) {
            ChecklistItemActivity.this.onClickGetDirections();
        }
    });

    Button doneness = (Button) findViewById(R.id.doneness);
    if (checklistItem.isDone()) {
        doneness.setTextColor(ContextCompat.getColor(ChecklistItemActivity.this, R.color.primary));
        doneness.setPaintFlags(doneness.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        doneness.setText(getResources().getString(R.string.complete));
        doneness.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check_box_accent_24dp, 0, 0, 0);
    } else {
        doneness.setTextColor(Color.BLACK);
        doneness.setPaintFlags(doneness.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
        doneness.setText(getResources().getString(R.string.mark_as_done));
        doneness.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check_box_outline_blank_black_24dp, 0, 0,
                0);
    }
    doneness.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ChecklistItemActivity.this.onClickIsDone();
        }
    });

    Button sendEmail = (Button) findViewById(R.id.send_email);
    if (checklistItem.getEmail() != null && !checklistItem.getEmail().equals("")) {
        sendEmail.setVisibility(View.VISIBLE);
        sendEmail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_SENDTO);
                intent.setData(Uri.parse("mailto:"));
                intent.putExtra(Intent.EXTRA_EMAIL, checklistItem.getEmail());
                intent.putExtra(Intent.EXTRA_TEXT,
                        getResources().getString(R.string.sent_from_rst_checklist_app));
                if (intent.resolveActivity(getPackageManager()) != null) {
                    startActivity(Intent.createChooser(intent, "Send e-mail"));
                }
            }
        });
    } else {
        sendEmail.setVisibility(View.GONE);
    }

    Button call = (Button) findViewById(R.id.call);
    if (checklistItem.getPhone() != null && !checklistItem.getPhone().equals("")) {
        call.setVisibility(View.VISIBLE);
        call.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:" + checklistItem.getPhone()));
                if (intent.resolveActivity(getPackageManager()) != null) {
                    startActivity(intent);
                }
            }
        });
    } else {
        call.setVisibility(View.GONE);
    }
}

From source file:com.dm.material.dashboard.candybar.fragments.dialog.AboutFragment.java

@Override
public void onClick(View view) {
    int id = view.getId();
    Intent intent = null;/*from   ww  w. j a  v  a2s. c  om*/
    if (id == R.id.email) {
        try {
            final Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                    getActivity().getResources().getString(R.string.about_email), null));
            email.putExtra(Intent.EXTRA_SUBJECT, (getActivity().getResources().getString(R.string.app_name)));
            getActivity().startActivity(
                    Intent.createChooser(email, getActivity().getResources().getString(R.string.email_client)));
            dismiss();
        } catch (ActivityNotFoundException e) {
            Log.d(Tag.LOG_TAG, Log.getStackTraceString(e));
        }
        return;
    } else if (id == R.id.link1) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(getActivity().getResources().getString(R.string.about_link_1_url)));
    } else if (id == R.id.link2) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(getActivity().getResources().getString(R.string.about_link_2_url)));
    } else if (id == R.id.dev_link1) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(getActivity().getResources().getString(R.string.about_dashboard_dev_github_url)));
    } else if (id == R.id.dev_link2) {
        intent = new Intent(Intent.ACTION_VIEW, Uri
                .parse(getActivity().getResources().getString(R.string.about_dashboard_dev_google_plus_url)));
    }

    try {
        getActivity().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.d(Tag.LOG_TAG, Log.getStackTraceString(e));
    }
}

From source file:ru.dublgis.androidhelpers.DesktopUtils.java

public static boolean sendSMS(final Context ctx, final String number, final String text) {
    try {//from  w w w  . j a  v  a 2s.  com
        //Log.d(TAG, "Will send sms \""+text+"\" to  \""+number+"\"");
        String uris = "smsto:";
        if (number != null && number.length() > 2)
            uris += number;
        if (verbose)
            Log.i(TAG, "URI: " + uris);
        Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uris));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("sms_body", text);
        ctx.startActivity(intent);
        return true;
    } catch (final Throwable e) {
        Log.e(TAG, "sendSMS exception: ", e);
        return false;
    }
}

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

@OnClick(R.id.email)
public void sendEmail() {
    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + user.getEmail().trim()));
    startActivity(intent);/*ww w  .  j  av  a  2s . c o  m*/
}