"java.lang.SecurityException: Permission Denial: starting Intent" sending an email on Android

I have an alertDialogBuilder that creates an Intent to send an email.

It worked well but since last week it stopped to work and is giving the following error:

java.lang.SecurityException: Permission Denial: starting Intent

I am using the same device all the time with Android versión 4.4.2 and on my gradle I am supporting the following versions:

minSdkVersion 16
targetSdkVersion 23

My code is:

    .setMessage("Do you want to send an email to " + getString(R.string.companyName) + "?")
    .setPositiveButton("Send",new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog,int id) {

                Intent gmail = new Intent(Intent.ACTION_SEND);
                gmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "myEmail@email.com" });
    .setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {

I know that there are two questions directly related with this question:

but I could not solve my problem with none of them. I also does not understand why it worked one week ago and now it stopped to work. I did not make any changes on Gmail application on my device and I have it installed on the device too.

What am I missing? I can paste the full stacktrace if required, I have put only the error name to reduce the size of the question.

EDIT: My error stacktrace is the following:

12-27 17:38:15.507 7816-7816/com.project.user.product E/AndroidRuntime: FATAL EXCEPTION: main
         Process: com.project.user.product, PID: 7816
         java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.SEND typ=plain/text cmp=com.google.android.gm/.ComposeActivityGmail (has extras) } from ProcessRecord{428b7c68 7816:com.project.user.product/u0a107} (pid=7816, uid=10107) not exported from uid 10048
             at android.os.Parcel.readException(Parcel.java:1472)
             at android.os.Parcel.readException(Parcel.java:1426)
             at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2222)
             at android.app.Instrumentation.execStartActivity(Instrumentation.java:1425)
             at android.app.Activity.startActivityForResult(Activity.java:3480)
             at android.app.Activity.startActivityForResult(Activity.java:3432)
             at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:842)
             at android.app.Activity.startActivity(Activity.java:3683)
             at android.app.Activity.startActivity(Activity.java:3651)
             at com.project.user.product.LoginActivity$7$2.onClick(LoginActivity.java:284)
             at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:157)
             at android.os.Handler.dispatchMessage(Handler.java:110)
             at android.os.Looper.loop(Looper.java:193)
             at android.app.ActivityThread.main(ActivityThread.java:5333)
             at java.lang.reflect.Method.invokeNative(Native Method)
             at java.lang.reflect.Method.invoke(Method.java:515)
             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
             at dalvik.system.NativeStart.main(Native Method)

Thanks in advance!



This statement says that your app requires that the user use Gmail, and more specifically, that the user use some older version of Gmail. Hence, your code does not support:

  • Users of devices where Gmail simply is not installed (which may or may not be a possibility, depending upon your app distribution channels)

  • Users of devices where they do not have access to Gmail (e.g., secondary device users)

  • Users of devices where they have Gmail disabled, because they use some other email account (e.g., me)

  • Users of devices where they have Gmail available, but do not normally use it or would prefer not to use it for this particular situation

  • Users of devices with a current version of Gmail, as com.google.andro‌​id.gm.ComposeActivit‌​yGmail is no longer available for direct launch by third-party apps, such as yours

The latter point is what is leading to your exception.

So, delete that statement. Also:

  • plain/text is not a valid MIME type. Use text/plain. Or, better yet, get rid of gmail.setType("plain/text"); entirely, as you are not using EXTRA_TEXT or EXTRA_STREAM, and that is what the MIME type of an ACTION_SEND Intent is tied to.

  • Delete gmail.setData(Uri.parse("myEmail@email.com"));, as ACTION_SEND does not use the data facet of the Intent.


 ? Session variables not working php
 ? Stopping emails going into spam (Gmail, Hotmail etc) POSTFIX
 ? Hyperlink in outlook which will open new mail with image embedded in body
 ? Configure SMTP host using YAML file in Spring boot
 ? whmcs compatibility with phpmailer 5.2.18
 ? How to add multiple recipients to this email code?
 ? android smtp with attachment of db file
 ? html not translated in email golang
 ? I get error when i'm trying to send email using libquickmail
 ? how to hide HTML tags when sending email by SMTP and tinymce for writting content