以下是我通过Gmail应用程序发送电子邮件的方式。通过意向发送电子邮件:SecurityException
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();
}
这不是开始的Gmail应用程序,但显示以下信息。
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
上有SOF对此一些问题,其中大部分是建议使用出口=真。但是当我启动另一个应用程序的活动时,我无法使用此解决方案。你能指导我吗?
类名(com.google.android.gm.ComposeActivityGmail)最近被改变。请检查并提供适当的类名。否则,您可以直接给emailIntent.setPackage(“com.google.android.gm”)而不是emailIntent.setClassName; – Rajasekhar
@Rajasekhar越来越android.content.ActivityNotFoundException:未发现处理意图的活动{act = android.intent.action.VIEW typ = text/plain pkg = com.google.android.gm(有额外功能)} –