Questions about compatibility with Android
From my understanding by reading the description, this library can be used to guess the type of a file based on its content, similar to the "file" command on linux.
- Am I correct?
- Could this also work on Android? If so, from which version?
- Is it possible to use it via Gradle? If so, what is the dependency I need to add? Is there a way to get updated about the version ? Maybe here?
- How much space does it add to the app's size?
- Where can I see all of the supported mime-types that it can return? Does it have support for those that are supported by Android (here) ?
OK was curious and tried it myself.
gradle:
implementation 'com.j256.simplemagic:simplemagic:1.16'
Code:
AsyncTask.execute {
val util = ContentInfoUtil()
val input = URL("https://img.freepik.com/free-vector/abstract-dynamic-pattern-wallpaper-vector_53876-59131.jpg?size=338&ext=jpg").openStream()
val info = util.findMatch(input)
Log.d("AppLog", "info:$info")
}
And the result:
info:jpeg, type JPEG, mime 'image/jpeg', msg 'JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16'
So to answer the questions:
- Seems so.
- Working even on Android Q beta 5. Tested also on emulator with Android API 16 (4.1).
- Yes. But not sure about updates. Just need to check from time to time on the website, I guess.
- Seems not to add much. The app became 2,522KB in side, and was 2,347KB . Rising in just ~200KB, and might be smaller when used with R8 minimizer. I wonder how much it reads from the InputStream and if it can be checked somehow, and how efficient it is. Probably very efficient and barely reads data.
- This I don't know yet.
Attached here the tiny sample project.
Good job on this library!
Thanks @AndroidDeveloperLB . I need to add Gradle support to all of my libraries. Sigh. So much to do.
@j256 Can you please confirm and/or answer what I wrote ?
Is there a list somewhere of all the file-types that you support? Does it at least include those that Android support (probably so) ?