내 요구 사항은 콘텐츠 공급자를 통해 다른 응용 프로그램에서 하나의 응용 프로그램의 자산 파일을 열 수 있습니다. 나는 몇 가지를 열 수 있어요문제 동안
(I는 컨텐트 프로 바이더의 구현이 파일을 노출하고있다) 파일 및 읽기,하지만 일부 파일을 여는 동안 나는 예외가 발생했습니다. 자산 파일을 여는 구현을 찾으십시오.
@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);
}
몇 번 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)
하지만, 내 PC에 또는 다른 방식으로 안드로이드 장치에서 열 수있는 동일한 파일
.누구나 나를 가리킬 수 있습니까, 어떤 시나리오에서 우리는이 예외를 얻을 것입니다.
미리 감사드립니다.
확장 프로그램을 이와 같이 변경하면 다른 파일을 기대하는 경우 앱에서 파일을 사용할 때 문제가 발생하지 않습니까? – clu