androidimage-galleryusb-otg

How to create a gallery app for usb otg?


I know a library called libaums and had implemented it, but I don't know how to open Images and Videos using their library.


Solution

  • According to https://github.com/magnusja/libaums, you can actually read a file from the storage using this:

    // read from a file
    InputStream is = new UsbFileInputStream(file);
    byte[] buffer = new byte[currentFs.getChunkSize()];
    is.read(buffer);
    

    Then your buffer contains the image data, so you can convert it to e.g. a Bitmap, like this:

    Bitmap bmp = BitmapFactory.decodeByteArray(buffer , 0, buffer .length);
    

    After that you can set it to an ImageView or whatever to show it to your user.

    To be short, find your File and implement this logic.