【发布时间】:2013-03-18 21:58:56
【问题描述】:
我一直在尝试绘图 api 示例:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html 并想保存绘图,我查看了以前的答案并尝试了给出的解决方案,但无法保存。
我已经用我用来保存的代码替换了 api 中浮雕按钮的代码,代码如下:
public boolean onOptionsItemSelected(MenuItem item) {
mPaint.setXfermode(null);
mPaint.setAlpha(0xFF);
switch (item.getItemId()) {
case COLOR_MENU_ID:
new ColorPickerDialog(this, this, mPaint.getColor()).show();
return true;
case EMBOSS_MENU_ID:
String path = Environment.getExternalStorageDirectory().toString();
OutputStream fOut = null;
File file = new File(path, "screentest.jpg");
try {
fOut = new FileOutputStream(file);
mBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
fOut.flush();
fOut.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我正在尝试将图像直接保存到 sdcard,当我单击按钮保存时,没有错误但它没有将文件保存到 sd 卡下,有人知道为什么这不起作用吗?
我也添加了权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
提前致谢
谢谢
编辑:我认为问题在于权限或创建文件的方式,我也尝试创建一个文件夹,但它也没有,我需要任何其他权限吗?
【问题讨论】:
-
对不起,我帮不上忙……
-
感谢您的帮助 MByD,会继续努力
-
我也遇到了同样的问题。但正如你所说,没有错误出现。但是当我点击保存按钮时,我得到了 ForceCLose 错误。请帮帮我。
标签: android