【发布时间】:2019-06-26 07:06:38
【问题描述】:
我想做一个应用程序来共享图库中的图片以供学习,并且我希望将图片重命名,因此我使用位图来检索图片的数据。但问题是文件总是返回空值。 我有一个代码,但我不知道问题出在哪里。
File file = new File(this.getFilesDir().getAbsolutePath(), "logo");
if (!file.exists()) {
file.mkdirs();
}
File iconf = new File(file, "icon_launcher.png");
iconf.createNewFile();
OutputStream ios = new FileOutputStream(iconf);
example.compress(Bitmap.CompressFormat.PNG, 80, ios);
ios.flush();
ios.close();
//String uricon= MediaStore.Images.Media.insertImage(getContentResolver(),iconf.getAbsolutePath(),"icon_launcher.png","drawing");
Uri iconurl = Uri.parse(iconf.getAbsolutePath());
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("image/png");
email.putExtra(Intent.EXTRA_STREAM, iconurl);
startActivityForResult(Intent.createChooser(email, "Envoyer par mail"), 1);
提前感谢您的帮助:)
【问题讨论】:
标签: java android image file bitmap