9

Getting to Java: The JNI

The previous chapter detailed the process of creating a HAL, an abstract interface between the Android framework and a novel bit of hardware.

That is only halfway there. Although a HAL is the canonical way of plumbing hardware into Android, it is not sufficient to make the device useful from Android Java programs. To do that, we need the Java’s Native Interface, the JNI.

The goal for this chapter is to cross the boundary into Android’s implementation language, Java. We’ll cross that boundary by coding a Java language application that connects to the proximity sensor using its HAL and that logs its status once every minute or so. We’ll achieve that goal in three steps:

  1. We’ll create a simple native application that ...

Get Inside the Android OS: Building, Customizing, Managing and Operating Android System Services now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.