简体   繁体   中英

How send a mail over gmail

i am getting data from edit text and try to send it over a gmail id but i am getting this "No apps perform this action" please tell me where i am doing wrong because i am new in android thanks

public void onClick(View v) {
        // TODO Auto-generated method stub
        if(v.getId() == R.id.send)
        {
            String name = objName.getText().toString();
            Intent email = new Intent(Intent.ACTION_SEND);
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{ "sgrpatel22@gmail.com"});
            email.putExtra(Intent.EXTRA_SUBJECT, name);
            email.setType("message/rfc822");
            startActivity(Intent.createChooser(email, "Send Mail :"));

        }
    }

Try

public void onClick(View v) {
        // TODO Auto-generated method stub
        if(v.getId() == R.id.send)
        {
            String name = objName.getText().toString();
            Intent email= new Intent(android.content.Intent.ACTION_SEND);
            email.setType("text/plain");
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{ "sgrpatel22@gmail.com"});
            email.putExtra(Intent.EXTRA_SUBJECT, name);
            startActivity(email);   

        }
    }

如果您使用的是SDK Simulator,则可能未安装GMail应用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM