获取通过gmail android发送的邮件事件

时间:2018-03-27 13:55:40

标签: android

如果在Android中发送或不发送电子邮件,我怎样才能获得gmail事件。我已经尝试了以下但无法实现结果

Intent helpIntent = new Intent(Intent.ACTION_SEND);
            helpIntent.setData(Uri.parse("mailto:"));
            helpIntent.setType("message/rfc822");
            helpIntent.setPackage("com.google.android.gm");
            helpIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"xyz@gmail.com"});
            helpIntent.putExtra(Intent.EXTRA_SUBJECT, "Mail Subject");
            helpIntent.putExtra(Intent.EXTRA_TEXT, " TEXT BODY");
            startActivityForResult(helpIntent,1);


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1)
    {
        if (resultCode == RESULT_OK)
        {
            Toast.makeText(this, "SENT", Toast.LENGTH_SHORT).show();
        }
        else
        {
            Toast.makeText(this, "DISCARD", Toast.LENGTH_SHORT).show();
        }
    }
}

0 个答案:

没有答案