Intent with setType(“message/rfc822”) for Android API Level before 2.3.3

前端 未结 3 1246
南方客
南方客 2021-01-13 19:15

I have a problem with setting type "message/rfc822" for intent to send e-mail with file attachment on Android emulator

相关标签:
3条回答
  • 2021-01-13 19:58

    I have made an application that uses URI example as you desired:

    if(v.getId()==R.id.button3)
    {
        intent=new Intent(Intent.ACTION_SEND);
        intent.setData(Uri.parse("mailto"));
        String[]to={"akshkatheria@gmail.com","megakatheria@gmail.com"};
        intent.putExtra(Intent.EXTRA_EMAIL, to);
        intent.putExtra(Intent.EXTRA_SUBJECT, "hello");
        intent.putExtra(Intent.EXTRA_TEXT, "hi");
        intent.setType("message/rfc822");
        chooser=intent.createChooser(intent, "send mail");
        startActivity(chooser); 
    }
    
    0 讨论(0)
  • 2021-01-13 20:02

    First, "to avoid a lot of applications in select list for user's choice", use ACTION_SENDTO and a mailto: Uri.

    Second, what you are experiencing is not "a problem of Android emulator" nor "old APIs". You need 1+ applications that are capable of handling the ACTION_SEND Intent and a MIME type of message/rfc822. There is no guarantee that any given device will support that combination, let alone any given emulator. Your code needs to handle that, just as if you use ACTION_GOBBLEDYGOOK or a MIME type of thisis/sonotreal or whatever.

    0 讨论(0)
  • 2021-01-13 20:13

    This is the solution. Use the below code, works perfectly...Got the solution after research.... :)

    Intent testIntent = new Intent(Intent.ACTION_VIEW);
    Uri data = Uri.parse("mailto:?subject=" + "blah blah subject" + "&body=" + 
    "blah blah body" + "&to=" + "sendme@me.com");  
    testIntent.setData(data);  
    startActivity(testIntent);  
    
    0 讨论(0)
提交回复
热议问题