user1387035
user1387035

Reputation: 209

Email application giving error "No applications can perform this action"

I am trying a simple email application.I referred this link http://www.mkyong.com/android/how-to-send-email-in-android/

But i am getting an error "No applications can perform this action" on emulator as well as on real device.How to overcome this error.Also as mentioned in the above link on send button,Choose an email client option appears.How to obtain this?Can someone guide me plz. Thanx in advance. My code is:

package com.example.androidsample4;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MakeComment extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.comment);
        TextView tv1=(TextView)findViewById(R.id.textView1);
        TextView tv2=(TextView)findViewById(R.id.textView2);
        TextView tv3=(TextView)findViewById(R.id.textView3);
        TextView tv4=(TextView)findViewById(R.id.textView4);
        TextView tv5=(TextView)findViewById(R.id.textView5);
        final EditText ed1=(EditText)findViewById(R.id.editText1);
        EditText ed2=(EditText)findViewById(R.id.editText2);
        final EditText ed3=(EditText)findViewById(R.id.editText3);
        final EditText ed4=(EditText)findViewById(R.id.editText4);
        ed3.setKeyListener(null);
        Button b1=(Button)findViewById(R.id.button1);
        b1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                  //String to = ed3.getText().toString();
                  String name = ed1.getText().toString();
                  String message = ed4.getText().toString();

                  Intent email = new Intent(Intent.ACTION_SENDTO);
                 // email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
                  //email.putExtra(Intent.EXTRA_CC, new String[]{ to});
                  //email.putExtra(Intent.EXTRA_BCC, new String[]{to});
                  email.putExtra(Intent.EXTRA_SUBJECT, name);
                  email.putExtra(Intent.EXTRA_TEXT, message);

                  //need this to prompts email client only
                  email.setType("message/rfc822");

                  startActivity(Intent.createChooser(email, "Choose an Email client :"));

            }
        });
    }

}

Upvotes: 0

Views: 3968

Answers (4)

Eire82
Eire82

Reputation: 21

This will display only email apps in your chooser:

     private void sendMail() {
        String recipientList = "[email protected],[email protected]";
        String[] recipients = recipientList.split(",");

        String subject = "App Subject - Help me";

        Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                "mailto","[email protected]", null));
        intent.putExtra(Intent.EXTRA_EMAIL, recipients);
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);

        startActivity(Intent.createChooser(intent, "Choose an Email Client"));
    }

Upvotes: 1

thanhbinh84
thanhbinh84

Reputation: 18454

Try this:

Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
            "mailto","[email protected]", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT");
startActivity(Intent.createChooser(emailIntent, "Send email..."));

Hope this helps.

Upvotes: 0

ThePCWizard
ThePCWizard

Reputation: 3348

We can't tell you where you are wrong as you have not posted your code. Try the below code(works both on device and emulator), if it works then there something wrong on your part and if doesn't try installing another e-mail client.

TextView email = (TextView) findViewById(R.id.email);
email.setText(Html.fromHtml("<a href=\"mailto:[email protected]\">E-mail</a>"));
email.setMovementMethod(LinkMovementMethod.getInstance());

"Choose an email client option" - That window is automatically populated by Android.

Upvotes: -1

Alexis C.
Alexis C.

Reputation: 93842

It won't work on the emulator unless you install an application that can handle email. By default no such app is installed. Try to install an email client on your real device and re-test this.

Upvotes: 1

Related Questions