tags:

views:

355

answers:

2

hi,
I could send mail from my Activity when i have already configured with any email account in android ,but in case if have not configured ,is there any way to launch email setup screen from my Activity ,or at least check whether email account is setup before sending a email.
If i haven't set up my email account then the following code takes me to compose SMS/MMS,which i don't want ,Please give your suggestion.

Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, "xxx.com"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "..."); emailIntent.putExtra(Intent.EXTRA_TEXT,"..."); emailIntent.setType("text/plain"); startActivity(Intent.createChooser(emailIntent, "Send mail..."));

A: 

is there any way to launch email setup screen from my Activity

That is not supported in the SDK, mostly becuase there is no "email setup screen" in Android. Various email applications may have setup screens, however different devices will have different email applications installed.

CommonsWare
Thank you Jim and commonsware for your comments,I am using android 1.6 and i test my application on android emulator.I have noted an default email app on my emulator.Is this only for emulator and nothing similar can be found on real device?.Jim i will be glad if you post some links guiding how to do that on 2.0.
ganesh
Devices may have the standard Android email application, or they may not. Devices may have the Gmail application, or they may not. Devices may have OEM-supplied email applications, or they may not. Users may have installed third-party email applications, or they may not.
CommonsWare
A: 

CommonsWare is right, there is no e-mail setup screen in Android as there is no default e-mail app. So you need to tell the user to setup an e-mail account before attempting to send e-mail.

To do this, set the intent type to "message/rfc822". This will call only the apps which can handle that MIME, in short, the e-mail apps.

Put startActivity in try, catch ActivityNotFoundException. When this exception is caught, you can inform the user to setup an e-mail account.

n_j