Hello,

In my app the user can select files and open them in the appropriate app (using 
an ACTION_VIEW intent). I need to do some work on the data before giving it to 
the other app. So I'm using a streaming solution : I've implemented a 
ContentProvider that implements openTypedAssetFile and writeDataToPipe (this 
method fills the output ParcelFileDescriptor created by openPipeHelper).

This works : I can open .pdf files, .txt files etc. The streaming seems 
correct. I can open images usings 3-party apps. However when I open an image 
using the Gallery, it doesn't work (Gallery shows a black screen), and I get 
the following exception :

fail to open myfile.jpg
UriImage(21890): java.io.FileNotFoundException: Not a whole file
I had a look at the Gallery source (here) and I could see that the exception is 
thrown here :

        try {
            if (MIME_TYPE_JPEG.equalsIgnoreCase(mContentType)) {
                InputStream is = mApplication.getContentResolver()
                        .openInputStream(mUri);
                mRotation = Exif.getOrientation(is);
                Utils.closeSilently(is);
            }
            **mFileDescriptor = mApplication.getContentResolver()
                    .openFileDescriptor(mUri, "r");**
            if (jc.isCancelled()) return STATE_INIT;
            return STATE_DOWNLOADED;
        } catch (FileNotFoundException e) {
            Log.w(TAG, "fail to open: " + mUri, e);
            return STATE_ERROR;
        }
However, once in the Gallery app, if I select "Set as wallpaper", then I can 
see my image, it is then well streamed. So the problem appears when Gallery 
opens.

After a deeper look (in the ContentResolver code etc.) I couldn't understand 
why it behaves this way. It seems that Gallery does not support streaming 
files. Is that right ? Do you have any idea ? I really lost with that right now.

Thanks

Vincent

-- 
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/d/optout.

Reply via email to