Programming with the zlib compression library in Android NDK
zlib
is a widely-used, lossless data compression library,
which is available for Android 1.5 system images or higher. This recipe discusses the basic usage of the zlib
functions.
Getting ready...
Readers are expected to know how to create an Android NDK project. We can refer to the Writing a Hello NDK program recipe of Chapter 1, Hello NDK for detailed instructions.
How to do it...
The following steps describe how to create a simple Android application which demonstrates the usage of zlib
library:
Create an Android application named
ZlibDemo
. Set the package name ascookbook.chapter7.zlibdemo
. Refer to the Loading native libraries and registering native methods recipe of Chapter 2, Java Native Interface for more detailed instructions.Right-click on the project ZlibDemo, select Android Tools | Add Native Support.
Add a Java file named
MainActivity.java
in thecookbook.chapter7.zlibdemo
package. TheMainActivity.java
file loads theZlibDemo...