Search code examples
androidemail-clientandroid-2.3-gingerbread

Do all android devices running on a 2.3.3 sdk have a default email client?


I've created the following in my 2.3.3 application (This is just a code snippet).

      else if(intentName.contains("Email"))
        {
            System.out.println();
            System.out.println("Button["+ i + "] intent name contains : EMAIL");
            System.out.println("Button["+ i + "] intent EMAIL contains: " + parameter);

            send_email = new Intent(Intent.ACTION_SEND);
            send_email.setType("message/rfc822");
            send_email.putExtra(Intent.EXTRA_EMAIL, parameter);
            send_email.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
            send_email.putExtra(Intent.EXTRA_SUBJECT, "");
            send_email.putExtra(Intent.EXTRA_TEXT,"");

            onClick[i] = new OnClickListener()
            {
            public void onClick(View arg0)
            {
                try
                {
                    con.startActivity(send_email);
                }
                catch(ActivityNotFoundException ex)
                {
                    Toast.makeText(con,  "No Email Clients Installed", Toast.LENGTH_LONG).show();
                }
            }};
        }

When I run this on the emulator - I get the toast - "No Email Clients Installed", which is perfectly fine because the emulator has no email clients. However it works fine on my device as expected since I have the default email client and gmail on my phone.

However since I'm developing for android 2.3.3+
Do all android devices with android 2.3.3. have a default email client? If they do then I can keep the current functionality and not have to make my own client.

That ^ was my original question, but now after looking into the emulator -I meant to ask:

Do all android devices with 2.3.3 sdks have a set up an email client option?

Thank you for the help!


Solution

  • There's absolutely zero way to guarantee that all devices running a particular android build will have an email client. It is part of the open source build (the Email app), but that's not to say somebody hasn't customized it and removed that app. It's probably safe to assume that it's there, but what you really should do is fail gracefully and show an error to the user either saying that your app requires an email app (if it does) or saying this functionality is disabled because no email app is present. Another option would be to provide them with a link to download an app from the market, etc.

    Side note: the emulator actually does have an e-mail app, it might just not be configured to handle message/rfc822 intents.