这是我的代码
QObject::connect(&model, SIGNAL(itemChanged(QStandardItem*)),
&myObject, SLOT(onItemChanged(QStandardItem*)));
但是当我收到的电子邮件没有格式时,我必须选择一个程序来打开它best source
答案 0 :(得分:0)
使用我的代码
File image = new File(Uri.parse("android.resource://" + C.PROJECT_PATH + "/drawable/" + R.drawable.icon_to_share).toString());
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
喜欢
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
File image = new File(Uri.parse("android.resource://" + C.PROJECT_PATH + "/drawable/" + R.drawable.icon_to_share).toString());
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
答案 1 :(得分:0)
您可以看到此answer。
首先,你需要在drawable文件夹中获取图像
imageName = "planet";
int resourceImage = getActivity().getResources().getIdentifier(imageName, getPackageName());
必须将可绘制资源保存在SDCard等内部存储中。
try {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceImage);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 50, bytes);
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "temporal.png");
boolean isCreated = file.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(bytes.toByteArray());
fileOutputStream.close();
} catch (IOException e) {
}
最后通过电子邮件发送图片你必须使用sharedintent:
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "this is a subject"); //set your subject
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "this is the message"); //set your message
String imagePath = Environment.getExternalStorageDirectory() +File.separator +"temporal.png";
File imageFileToShare = new File(imagePath);
Uri uri = Uri.fromFile(imageFileToShare);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share image"));