Android Email Intent
Solution 1:
try to put break;
after each case
xxx {}
Solution 2:
The mail intent is just available if you use it on a real device where a mail client is installed. I guess you have problems in the emulator. To make it work there, you need a client installed that supports this intent. I guess you get a error like:
android.content.ActivityNotFoundException:NoActivityfoundtohandleIntent
Solution 3:
Solution 4:
The developer guide for common intents warns about the case that if no app with an Activity responding to the intent an exception is being thrown:
Caution: If there are no apps on the device that can receive the implicit intent, your app will crash when it calls startActivity(). To first verify that an app exists to receive the intent, call resolveActivity() on your Intent object. If the result is non-null, there is at least one app that can handle the intent and it's safe to call startActivity(). If the result is null, you should not use the intent and, if possible, you should disable the feature that invokes the intent.
For example:
privatevoidsendEmail(String address) {
Intent emailIntent = newIntent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, newString[]{"xxxxxxxx@gmail.com"});
emailIntent.setType("plain/text");
if (emailIntent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(emailIntent, "Send email..."));
} else {
// TODO: Tell your user about it
}
}
Alternatively you could do the check in your onCreate()
to hide the button altogether.
Post a Comment for "Android Email Intent"