问题描述
告诉我如何实现从相机发送多张图像。本示例仅适用于1张图片。我查看了论坛,自己没有找到任何东西,也许有人知道答案,请告诉我。 在此示例中,我仅通过photoURI变量发送1张图像,对于我来说,我有兴趣发送2-3张相机快照的图像。
我的代码段:
@Override
public void onClick(View v) {
String emailSubject = textSubject.getText().toString();
String emailText = textMessage.getText().toString();
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_EMAIL,new String[]{odooAdress});
intent.putExtra(Intent.EXTRA_SUBJECT,emailSubject);
intent.putExtra(Intent.EXTRA_TEXT,emailText);
intent.putExtra(Intent.EXTRA_STREAM,photoURI);
intent.setType("message/rfc822");
intent.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmailExternal");
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
}
mUriList.clear();
}
});
return root;
}
@Override
public void onActivityResult(int requestCode,int resultCode,Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case RQS_LOAD_IMAGE:
Uri imageUri = data.getData();
mUriList.add(imageUri);
mFileListAdapter.notifyDataSetChanged();
break;
case RQS_SEND_EMAIL:
break;
}
}
}
private File createImageFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName,".jpg",storageDir
);
mCurrentPhotoPath = image.getAbsolutePath();
return image;
}
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
Toast.makeText(getActivity(),"Error!",Toast.LENGTH_SHORT).show();
}
if (photoFile != null) {
photoURI = FileProvider.getUriForFile(getActivity(),"xyz.devdiscovery.example.FileProvider",photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,photoURI);
startActivityForResult(takePictureIntent,REQUEST_TAKE_PHOTO);
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)