Loading native libraries and registering native methods
Native code is usually compiled into a shared library and loaded before the native methods can be called. This recipe covers how to load native libraries and register native methods.
Getting ready
Please read the recipes in Chapter 1, Hello NDK, to set up the Android NDK development environment if you haven't done so already.
How to do it…
The following steps will show you how to build an Android application that demonstrates loading native libraries and registering native methods:
Start Eclipse, select File | New | Android Project. Enter the value for Project Name as
NativeMethodsRegister
. Select Create new project in workspace. Then, click on Next.In the next window, select the latest version of Android SDK, then click on Next to go to the next window.
Specify the package name as
cookbook.chapter2
. Select the Create Activity checkbox, and specify the name asNativeMethodsRegisterActivity
. Set the value for Minimum SDK as 5 (Android 2...