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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.