"java.lang.SecurityException: Permission Denial: starting Intent" sending an email on Android
<p>I have an <code>alertDialogBuilder</code> that creates an Intent to send an email.</p>

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

<blockquote>
  <p>java.lang.SecurityException: Permission Denial: starting Intent</p>
</blockquote>

<p>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:</p>

<pre><code>minSdkVersion 16
targetSdkVersion 23
</code></pre>

<p>My code is:</p>

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

                Intent gmail = new Intent(Intent.ACTION_SEND);
                gmail.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
                gmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "myEmail@email.com" });
                gmail.setData(Uri.parse("myEmail@email.com"));
                gmail.setType("plain/text");
                startActivity(gmail);
          }
    })
    .setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                   dialog.cancel();
            }
    });
</code></pre>

<p>I know that there are two questions directly related with this question:</p>

<ul>
<li><a href="https://stackoverflow.com/questions/40871477/permission-denial-starting-intent-sharing-with-gmail">Permission Denial: starting Intent sharing with gmail</a></li>
<li><a href="https://stackoverflow.com/questions/40627368/send-email-through-intent-securityexception">Send email through Intent : SecurityException</a></li>
</ul>

<p>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.</p>

<p>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.</p>

<p><strong>EDIT:</strong> My error stacktrace is the following:</p>

<pre><code>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)
</code></pre>

<p>Thanks in advance!</p>