Hi,
The following works fine on 2.1 emulator.
It does NOT work on a 2.1 device :(.

I pull encrypted image from my storage and want to show it using a
default built in image viewer.
For that I have built my own ImageProvider class.

Here is how I invoke it:
// pass data to image provider
ImageProvider.setPictureData(pictureData);

// fire up default image viewer
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(ImageProvider.CONTENT_URI, "image/*");
this.startActivity(intent);

ImageProvider is my own class where in public ParcelFileDescriptor
openFile(Uri uri, String mode) method I do the following:

// we need to write the picture to a temp file
FileOutputStream fileStream = ctx.openFileOutput(FILE_NAME,
Context.MODE_PRIVATE );
fileStream.write(pictureData);
fileStream.flush();
fileStream.close();

// now open the file descriptor
ParcelFileDescriptor result =
ParcelFileDescriptor.open(ctx.getFileStreamPath(FILE_NAME),
        ParcelFileDescriptor.MODE_READ_ONLY);
// according to Dianne we can now delete the file;
// it will be deleted by the system once the last
// user closes the file
ctx.deleteFile(FILE_NAME);

return result;


If you ask why I delete the file immediately it is because it was
encrypted for a reason and I don't want to leave it in the file
system.
Also please note the comment there. I found it somewhere in these news
groups, that I can delete the file once it was open by file descriptor
and it will be hidden from anyone and deleted once last user closes
handle.

What is different between emulator and real device? It worked fine
until 2.1 upgrade now users can't see the pictures anymore. Why does
it work fine on emulator and not on a device?

Thanks for any hints.

-- 
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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to