Images as Email Attachment

后端 未结 2 1107
一整个雨季
一整个雨季 2021-01-07 17:04

I want to build an application where i am able to attach an image with the email, open the image and set it as my wallpaper. I wanted to make it cross platform so can you te

相关标签:
2条回答
  • 2021-01-07 17:47

    Hello if you want to just attach your image with email then using this code you can do this..

    ArrayList<String> str = new ArrayList<String>() ;
    ArrayList<Uri> uris = new ArrayList<Uri>();
    
    //convert from paths to Android friendly Parcelable Uri's
    for(int i=0; i<ayy_Images.size(); i++)
    {
       if(ayy_Images.get(i) == null)
        {
           str.add("");
        }
        else
        {
           str.add(ayy_Images.get(i));
        }
    }
    
    for (String file : str)
    {
       File fileIn = new File(file);
       Uri u = Uri.fromFile(fileIn);
       uris.add(u);
    }
    
    startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND_MULTIPLE).setType("audio/wav").setType("image/jpeg").setType("message/rfc822")
                                .putExtra(Intent.EXTRA_EMAIL, emails)
                                .putExtra(Intent.EXTRA_SUBJECT, subject)
                                .putExtra(Intent.EXTRA_TEXT, strDetails).putExtra( android.content.Intent.EXTRA_STREAM, uris), "Send your email in:"));             
    

    ayy_Images is a ArrayList which contains the list of images.

    0 讨论(0)
  • 2021-01-07 18:04

    For iPhone sdk you attach image as :

    NSData *photoData = UIImageJPEGRepresentation([UIImage imageNamed:@"anImage.png"], 1);
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    [picker addAttachmentData:photoData mimeType:@"image/jpg" fileName:[NSString stringWithFormat:@"image001.png"]];
    

    For " open the image and set it as my wallpaper "

    It is not possible via code in iPhone. You have to use the Settings.app

    0 讨论(0)
提交回复
热议问题