我正在尝试拍照或从图库中选择它,压缩它并将其保存在手机上的单独文件夹中。照片被拍摄并放入 $scope.test2 = function (name)
{
var res = 'http://example.com?from=' + name;
var range = document.createRange();
range.selectNode(res); // here getting error
window.getSelection().addRange(range);
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copy email command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
window.getSelection().removeAllRanges();
}
但我无法在imageview
找到它,即使在几分钟之后也是如此。可能是什么问题?
gallery
String mPhotoLocation;
压缩图片
private void takePhoto() {
Intent takePhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File photoFile = null;
try {
photoFile = photoPath();
} catch (IOException e) {
e.printStackTrace();
}
Uri photoURI = FileProvider.getUriForFile(getContext(),
getContext().getApplicationContext().getPackageName() + ".provider",
photoFile);
takePhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePhoto, REQUEST_CAMERA);
}
答案 0 :(得分:1)
保存图像后调用此方法
public static void notifySystemGallery(Context context, File file) {
if (file == null || !file.exists()) {
Log.e(TAG, "notifySystemGallery: the file do not exist.");
return;
}
try {
MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(),
file.getName(), null);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));
}