On Fri, Feb 22, 2013 at 11:53 AM, skink <[email protected]> wrote:
> btw could you post four openAssetFile method?
>
I removed it in the meantime from my code base, plus there was a lot of
unrelated leftovers from other tests, but if I reconstruct the substantial
parts it was along the lines of:
public AssetFileDescriptor openAssetFile (Uri uri, String mode) throws
FileNotFoundException {
ParcelFileDescriptor [] pipe = null;
long dataLen = AssetFileDescriptor.UNKNOWN_LENGTH;
try {
String assetPath = ensureCorrectAssetPath (uri.getPath ());
AssetFileDescriptor inFd = getContext ().getAssets ().openFd
(assetPath);
dataLen = inFd.getLength ();
pipe = ParcelFileDescriptor.createPipe ();
new TransferThread (
new FileInputStream (inFd.getFileDescriptor ()),
new ParcelFileDescriptor.AutoCloseOutputStream (pipe[1])
).start ();
} catch (IOException e) {
// handle exception
}
return new AssetFileDescriptor (pipe[0], 0, dataLen);
}
TransferThread was a slight variation of Mark's TransferThread (linked from
his SO question).
(Note also that this is just a test - it won't work as a general-purpose
openAssetFile() implementation as some assets (the compressed ones in
particular) won't work with openFd() - oggs do however.)
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.