Send Email Intent
when you will change your intent.setType like below you will get
intent.setType("text/plain");
Use android.content.Intent.ACTION_SENDTO
to get only the list of e-mail clients, with no facebook or other apps. Just the email clients.
Ex:
new Intent(Intent.ACTION_SENDTO);
I wouldn't suggest you get directly to the email app. Let the user choose his favorite email app. Don't constrain him.
If you use ACTION_SENDTO, putExtra does not work to add subject and text to the intent. Use Uri to add the subject and body text.
EDIT:
We can use message/rfc822
instead of "text/plain"
as the MIME type. However, that is not indicating "only offer email clients" -- it indicates "offer anything that supports message/rfc822 data". That could readily include some application that are not email clients.
message/rfc822
supports MIME Types of .mhtml, .mht, .mime
Using Android Intent.ACTION_SEND for sending email
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.setType("application/octet-stream");
EDIT:
You could try setting the type to "message/rfc822"
as well.
try this...
ACTION_SEND force sending with email
Try to setType message/rfc822
instead of text/plain
Action send mail to with file Android 11
solved with replacing:
Intent email_intent = new Intent(Intent.ACTION_SEND);
email_intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
and in <manifest> </manifest>
putting:
<queries>
<intent>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="*/*" />
</intent>
</queries>
Android Studio mailto Intent doesn't show subject and mail body
try out this code, it worked for me.
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject here");
intent.putExtra(Intent.EXTRA_TEXT,"Body Here");
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
also add intent filter in android manifest.
<activity ...>
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Sending email with attachment using SENDTO on some devices doesn't work
Try to resolve activity via ACTION_SENDTO, but actually sending via ACTION_SEND.
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", "", null));
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TEXT, text);
intent.putExtra(Intent.EXTRA_STREAM, getSnapshotUri(snapshot, context, event));
List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
if (resolveInfos.size() == 0) {
new AlertDialog.Builder(context)
.setMessage(R.string.no_mail_app)
.setPositiveButton(R.string.ok, null)
.show();
} else {
String packageName = resolveInfos.get(0).activityInfo.packageName;
String name = resolveInfos.get(0).activityInfo.name;
intent.setAction(Intent.ACTION_SEND);
intent.setComponent(new ComponentName(packageName, name));
context.startActivity(intent);
}
Related Topics
Problem to Load Flv Video in Webview
Appcompatv7 - V21 Navigation Drawer Not Showing Hamburger Icon
Start Application Knowing Package Name
"Realm Migration Needed", Exception in Android While Retrieving Values from Realm Db
Add a Header to a Gridview (Android)
Redraw a Single Row in a Listview
Android Setting with Textview for Hebrew Text
Error:Execution Failed For Task ':App:Transformclasseswithjarmergingfordebug'
How to Open a PDF via Intent from Sd Card
Googlesignatureverifier Signature Not Valid Message (Google Play Services 9.0.0)
Realmchangelistener Does Not Get Called When Realm Gets Updated in Notificationlistenerservice
How to Programmatically Enable and Disable Flight Mode on Android 4.2