Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open files in Android with default viewer using jCIFS

I'm using the free jCIFS library to connect to my NAS device via CIFS, and it's working great. I can connect and get a list of filenames, etc. without any issues.

Now I'd like to open one of the files in the default Android application - i.e. a music file should be opened in the music player, an image in the gallery, video file in a video player and so forth. The issue is not really about getting the MIME type and so on. The issue is that I don't want to download the files first, they should be streamed.

Does anyone know how this can be achieved? I know that CifsManager (another third party application) is capable of doing something similar, but it doesn't use jCIFS and it requires root access to mount drives. It is essential that my application doesn't require root access.

You can find the jCIFS library here: http://jcifs.samba.org/

like image 497
Michell Bak Avatar asked Nov 06 '11 22:11

Michell Bak


1 Answers

You can use the SmbFileInputStream to read the file.
Please go through the documentation jcifs.smb.SmbFileInputStream

like image 117
aNi Avatar answered Oct 07 '22 12:10

aNi