10

I am making an app in which i am going to provide a feedback feature to my customers. To acheive this i have created a small dialogue box where user can input there feedback and send it to my mail ID. I tried some code snippets which i found on internet but whenever i try to send an email from emulator or actual device, i am gettig an error "No Application can perform this action".

Here is my code :-

public void emailDialog()
{
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("Feedback");
    alertDialog.setMessage("Please tell us that what you feel about our product. If you are facing any problem or found any bug then please report to us. Your review is important to us. Thanks!!");
    final EditText input = new EditText(this);
    input.setLines(8);
    alertDialog.setView(input);
    alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            String address = "varundroid@gmail.com";
            String subject = "FeedBack";
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, address);
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, value);
            CompleteTaskManager.this.startActivity(Intent.createChooser(emailIntent, "Send Email.."));
        }
    });
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {
        // Canceled.
      }
    });
alertDialog.show();
}

Please Help.

Varundroid
  • 9,135
  • 14
  • 63
  • 93
  • I could understand you getting it on the emulator which may not have an email app. On a device however that's puzzling. Could you please double-check using LogCat that it is the same error on device and emulator. – Jim Blackler Apr 25 '11 at 14:00
  • @Jim yes that is what i am wondering. I thought it's because my emulaotr doesn't have an email app but when i tried it on real device, it was prompting me the same error and strange thing is that my email app is fully configured and functional on my device and still i am facing this error. – Varundroid Apr 25 '11 at 14:09

2 Answers2

18

I think you need to set the type of the intent object. Can you try the following

emailIntent.setType("message/rfc822");

or

emailIntent.setType("text/plain");
Josnidhin
  • 12,469
  • 9
  • 42
  • 61
  • thansk man you are a lifesaver lol and please don't laugh on my stupid mistake :P.....btw now everything is working fine but i am not getting the address field in my email app's "TO" field. any idea why is it so? – Varundroid Apr 25 '11 at 14:31
  • 2
    no problem...The address variable has to be a String array I think. Something like String address = {"varundroid@gmail.com"}; – Josnidhin Apr 25 '11 at 14:41
0

If someone's trying to do this from XML preferences, I accomplished this by adding in the Preference element an intent with as action ACTION_SENDTO and as data mailto:your.email@domain.com. Hope this could help someone.

bd95
  • 173
  • 1
  • 8