Android: java.lang.SecurityException: Permission Denial: start Intent to send mail

0

I have created an application containing GIF Maker and i can send mail to remove specific gif from server but i can send mail to remove gif that time my application is crush.

05-19 12:09:23.359 20090-20090/com.aspiration.gifmaker E/AndroidRuntime: FATAL EXCEPTION: main
     Process: com.aspiration.gifmaker, PID: 20090
     java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.SEND typ=plain/text flg=0x1 cmp=com.google.android.gm/.ComposeActivityGmail VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} clip={plain/text T:Hello Admin, 
     The User is Reporting an Issue in to the GIF Maker With GIF ID:http://..../android/19-05-2017/1495175373Gif_1495175338634.gif
     Please remove this GIF from community.} (has extras) } from ProcessRecord{97ee9a9 20090:com.aspiration.gifmaker/u0a305} (pid=20090, uid=10305) not exported from uid 10098
         at android.os.Parcel.readException(Parcel.java:1621)
         at android.os.Parcel.readException(Parcel.java:1574)
         at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3182)
         at android.app.Instrumentation.execStartActivity(Instrumentation.java:1541)
         at android.app.Activity.startActivityForResult(Activity.java:4298)
         at android.app.Activity.startActivityForResult(Activity.java:4245)
         at android.app.Activity.startActivity(Activity.java:4582)
         at android.app.Activity.startActivity(Activity.java:4550)
         at com.aspiration.gifmaker.adapter.GifGridViewAdapter.sendmail(GifGridViewAdapter.java:221)
         at com.aspiration.gifmaker.adapter.GifGridViewAdapter$3.onClick(GifGridViewAdapter.java:152)
         at android.view.View.performClick(View.java:5721)
         at android.view.View$PerformClick.run(View.java:22620)
         at android.os.Handler.handleCallback(Handler.java:739)
         at android.os.Handler.dispatchMessage(Handler.java:95)
         at android.os.Looper.loop(Looper.java:148)
         at android.app.ActivityThread.main(ActivityThread.java:7409)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

here my code ..

  String[] TO = {mContext.getResources().getString(R.string.to_emai)};
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setData(Uri.parse("mailto:"));
    emailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
    emailIntent.setType("plain/text");
    emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, mContext.getResources().getString(R.string.email_subject));
    emailIntent.putExtra(Intent.EXTRA_TEXT, mContext.getResources().getString(R.string.emailbody1) + url + mContext.getResources().getString(R.string.emailbody2));

    try {
        mContext.startActivity(emailIntent);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(mContext, mContext.getResources().getString(R.string.no_client_message), Toast.LENGTH_SHORT).show();
    }
java
android
email
asked on Stack Overflow May 20, 2017 by Ashish Virani

2 Answers

0

Already you settype as "plain/text" .so Mail format is only plain/text so remove your gif files in code. so remove url (its contain gif) in Intent putExtra

 emailIntent.putExtra(Intent.EXTRA_TEXT, mContext.getResources().getString(R.string.emailbody1) + mContext.getResources().getString(R.string.emailbody2));
answered on Stack Overflow May 20, 2017 by sasikumar
0
android.permission.WRITE_EXTERNAL_STORAGE

Give Run time Permission.

answered on Stack Overflow Nov 23, 2019 by Mihir Akoliya

User contributions licensed under CC BY-SA 3.0