Chapter 9. Porting an Existing Application to Android with NDK

In this chapter, we will cover the following recipes:

  • Porting a command-line executable to Android with an NDK build system
  • Porting a command-line executable to Android with an NDK standalone compiler
  • Adding GUI to a ported Android app
  • Using background threads at porting

Introduction

The previous chapter covered various techniques of porting a native library to Android with NDK. This chapter discusses the porting of native applications.

We will first introduce how to build a native command-line application for Android with an Android NDK build system and the standalone compiler provided by NDK. We will then add a GUI for the ported application. Finally, we illustrate using a background thread to do the heavy processing and sending the progress update message from the native code to the Java UI thread for GUI updates.

We will use the open source Fugenschnitzer program throughout this chapter. It is a content-aware image resizing program based on the Seam Carving algorithm. The basic idea of this algorithm is to change the size of an image by searching for and manipulating the seams (a seam is a path of connected pixels from top to bottom, or left to right) from the original image. The algorithm is able to resize an image while trying to keep the important information. For readers who are interested in the program and the algorithm, refer to the project's main page at http://fugenschnitzer.sourceforge.net/main_en.html for more details. Otherwise, we can ignore the algorithm and focus on how the porting is done.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset