Here is how I'm sending email through Gmail App.
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
emailIntent.setType("text/html");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Puzzle");
emailIntent.putExtra(Intent.EXTRA_TEXT, someTextHere));
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(attachmentFile));
try {
startActivityForResult(emailIntent, SHARE_PUZZLE_REQUEST_CODE);
} catch (ActivityNotFoundException e) {
showToast("No application found on this device to perform share action");
} catch (Exception e) {
showToast(e.getMessage());
e.printStackTrace();
}
It's not starting the Gmail App but shows the following message.
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.SEND typ=text/html cmp=com.google.android.gm/.ComposeActivityGmail (has extras) } from ProcessRecord{8293c64 26854:com.xxx.puzzleapp/u0a383} (pid=26854, uid=10383) not exported from uid 10083
There are few questions regarding this on SOF and most of them are suggested to use exported = true. But I cannot use this solution as I'm launching the activity of another app. Could you please guide me?