【发布时间】:2011-12-12 06:12:45
【问题描述】:
我想构建一个应用程序,我可以在其中附加图像和电子邮件,打开图像并将其设置为我的墙纸。我想让它跨平台,所以你能告诉我它是否可以使用 phonegap 还是我必须为 iphone 和 android 构建一个本机应用程序?
【问题讨论】:
我想构建一个应用程序,我可以在其中附加图像和电子邮件,打开图像并将其设置为我的墙纸。我想让它跨平台,所以你能告诉我它是否可以使用 phonegap 还是我必须为 iphone 和 android 构建一个本机应用程序?
【问题讨论】:
您好,如果您只想通过电子邮件附上您的图片,那么您可以使用此代码执行此操作..
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 是一个包含图像列表的 ArrayList。
【讨论】:
对于 iPhone sdk,您将图像附加为:
NSData *photoData = UIImageJPEGRepresentation([UIImage imageNamed:@"anImage.png"], 1);
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
[picker addAttachmentData:photoData mimeType:@"image/jpg" fileName:[NSString stringWithFormat:@"image001.png"]];
对于“打开图片并将其设置为我的壁纸”
这是不可能通过 iPhone 中的代码实现的。您必须使用 Settings.app
【讨论】: