<provider android:name=".ImageProvider" android:authorities="com.path.to.package" />
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
File file = new File(....);
ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
return parcel;
}
byte[] imageData = ...;
Parcel parcel = Parcel.obtain();
parcel.writeByteArray(imageData, 0, imageData.length);
return parcel.getFileDescriptor();