我的要求是通过内容提供商从另一个应用程序打开一个应用程序的资产文件.(我使用ContentProvider实现公开该文件)
我能够打开几个文件并阅读,但在打开一些文件时我会遇到异常.请找到打开资产文件的实现.
@Override
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
AssetManager am = getContext().getAssets();
String file_name = uri.getLastPathSegment();
if(file_name == null)
throw new FileNotFoundException();
AssetFileDescriptor afd = null;
try {
afd = am.openFd(file_name);
} catch (IOException e) {
e.printStackTrace();
}
return afd;//super.openAssetFile(uri, mode);
}
Run Code Online (Sandbox Code Playgroud)
有时候am.openFd(file_name);会抛出一个例外说,
java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
at android.content.res.AssetManager.openAssetFd(Native Method)
at android.content.res.AssetManager.openFd(AssetManager.java:329)
at com.pineone.swfinstaller.SwfProvider.openAssetFile(SwfProvider.java:25)
at android.content.ContentProvider$Transport.openAssetFile(ContentProvider.java:218)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:234)
at android.os.Binder.execTransact(Binder.java:288)
at dalvik.system.NativeStart.run(Native Method) …Run Code Online (Sandbox Code Playgroud) 当我在那个图像上移动手指时,我需要帮助使触摸的位图图像区域透明(看起来像擦除).
我有一个带Alpha通道的PNG文件.我想将触摸的像素变为透明,以便用户可以感觉到他实际上正在擦除它.
为此,我使用框架布局加载2层.下层用于内容,上层是用于擦除的Imageview.当用户触摸并在其上移动手指时,我需要擦除上层.
我没有得到如何让它透明.任何人都可以帮助我.如果可能的话,请指导我任何示例代码,因为我对这个图像处理很新.
提前致谢.
我需要一些帮助,在多个图像中围绕其中心旋转一个图像,这些图像被绘制到android中的画布.
我正在将图像加载到画布,如下所示.
canvas.drawBitmap(mMachineBackground, 0, 0, null);
canvas.drawBitmap(mMachineRotator, 0, 0, null);
Run Code Online (Sandbox Code Playgroud)
我想只围绕轴的中心旋转第二个位图,而不是旋转整个画布(也包括第一个位图).
提前致谢.