单击按钮时调用邮件客户端 [英] Calling a mail client when clicking a button

查看:121
本文介绍了单击按钮时调用邮件客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView连接到解析服务器数据通过解析.当我单击ListView的单个项目时,它将转到单个项目视图.那里我有一个电子邮件按钮,我需要的是当我单击该电子邮件按钮,并且电子邮件客户端应打开.具有该特定单个项目的电子邮件ID.电子邮件ID存储在parse数据库中的一列中.有谁知道请致电该怎么做?

I have a ListView connected to parse server data is coming through parse. when I click single item of the ListView it goes to single item view. there i have a button for email , what i need is when I click that email button and email client should open .with that particular single items email id . email id's are stored in a column in parse database . any one knows please tel how to do this ?

我的数据库是解析服务器,我需要从 解析列.每个单项都有不同的电子邮件...电子邮件列 名称是电子邮件"

my database is parse server , I need to get emails dynamically from a parse column. each singe item has a different email ... email column name is "email"

*

我在下面使用了一个答案并进行了这样的编辑,但没有显示收件人的电子邮件

I used an answer below and edited like this but no receiver email showing

*

btn1 = (Button)findViewById(R.id.button5);
            btn1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    String phnoo = object.getString("email");


                    Intent intent = new Intent(Intent.ACTION_SENDTO);
                   intent.setType("message/rfc822");
                    intent.setData(Uri.parse("mailto:"+phnoo));
                    startActivity(intent);


我的用于调用电子邮件客户端的Java代码

my java code for calling email client

  btn1 = (Button) findViewById(R.id.button5) ;
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phno="email";

                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri data = Uri.parse("mailto:" +phno);
                intent.setData(data);
                startActivity(intent);
            }
        });

按钮的XML代码

xml code for button

   <Button
            android:id="@+id/button5"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="E-MAIL"

            android:layout_weight="1"
            android:background="#EFEFEF"/>

推荐答案

我认为这会对您有所帮助

I think this would help you

Intent in = new Intent(Intent.ACTION_SEND);
in.setType("plain/text");
in.putExtra(Intent.EXTRA_EMAIL, new String[] { "mail id" });
in.putExtra(Intent.EXTRA_SUBJECT, "subject");
in.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(in, ""));

这篇关于单击按钮时调用邮件客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆