How to get notified for send or cancel of an email

拟墨画扇 提交于 2019-12-12 05:14:15

问题


I am starting Email client using intent from my activity (Either native email or gmail). I just want to get notified into my activity when user presses send button or discards the email. I just want to start another activity when user press send button and want to show a dialog when user discards the email.

Here is my code

Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("message/rfc822");
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"email@something.com"});
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Test Mail");
    emailIntent.putExtra(Intent.EXTRA_TEXT, "Test Mail Subject");
    startActivityForResult(emailIntent, REQ_CODE);


public void onActivityResult(int requestCode, int resultCode,
        Intent data) {

    if(requestCode == REQ_CODE){
        Toast.makeText(getApplicationContext(), "resultCode  "+resultCode, Toast.LENGTH_LONG).show();
        //if(resultCode == RESULT_OK){


        //}
    }
}

Thanks in Advance..


回答1:


This is not possible. ACTION_SEND is not designed for use with startActivityForResult(), and nobody, let alone whatever email client the user happens to choose, is obligated to call setResult() to let you know what the user did.



来源:https://stackoverflow.com/questions/15786215/how-to-get-notified-for-send-or-cancel-of-an-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!