By Feipeng Liu

Create Android apps utilizing local C/C++ with the professional counsel contained during this cookbook. From simple exercises to complicated multimedia improvement, it is helping you harness the total energy of Android NDK.


  • Build, debug, and profile Android NDK apps
  • Implement a part of Android apps in local C/C++ code.
  • Optimize code functionality in meeting with Android NDK.

In Detail

Building Android functions might frequently suggest that you just spend your whole time operating in Java. There are notwithstanding occasions whilst this isn't the best or top process for the appliance being outfitted. this is often the place Android NDK is available in. Android NDK permits the developer to write down in local C/C++, supplying you with the facility to reuse code and libraries and likewise, typically, elevate the rate and potency of your application.

The "Android local improvement equipment Cookbook" can help you recognize the improvement, construction, and debugging of your local Android functions. we'll detect and research JNI programming and crucial NDK APIs similar to OpenGL ES, and the local program API. we'll then discover the method of porting current libraries and software program to NDK. by way of the top of this publication it is possible for you to to construct your individual apps in NDK apps.

"Android local improvement package Cookbook" starts off with simple recipes that can assist you within the development and debugging of local apps, and JNI programming. The recipes disguise numerous subject matters of software improvement with Android NDK similar to OpenGL programming and Multimedia programming. we'll start with an easy recipe, hi NDK, prior to relocating directly to conceal complicated issues with recipes on OpenGL ES that target 2nd and 3D pix, in addition to recipes that debate operating with NDK and exterior APIs. when you are trying to find how you can make your program on hand in Android and take measures to spice up your application’s functionality, then this Cookbook is for you.

What you'll study from this book

  • Develop Android apps in C/C++ with out a unmarried line of Java.
  • Program 2D/3D photographs with either OpenGL ES 1x and 2.0 in Android NDK.
  • Write multi-threaded Android apps in Android NDK.
  • Port current C/C++ libraries and purposes to Android with NDK.
  • Develop multimedia Android apps with Android NDK.


This publication is written in a Cookbook kind, starting with recipes which specialise in assisting builders make their software/application on hand in Android.

Who this e-book is written for

Android builders who are looking to research Android NDK programming, or improve multimedia and video games in Android NDK will take advantage of this book.

Show description

Read or Download Android Native Development Kit Cookbook PDF

Similar Programming books

Embedded C

For those that are approximately to put in writing their first embedded application - or were suffering to benefit approximately this significant zone - this ebook will retailer weeks of attempt.

Cocoa Design Patterns

“Next time a few child exhibits up at my door inquiring for a code evaluate, this can be the booklet that i'm going to throw at him. ”   –Aaron Hillegass, founding father of huge Nerd Ranch, Inc. , and writer of Cocoa Programming for Mac OS X   Unlocking the secrets and techniques of Cocoa and Its Object-Oriented Frameworks   Mac and iPhone builders are frequently beaten via the breadth and class of the Cocoa frameworks.

C++ Primer (5th Edition)

Bestselling Programming educational and Reference thoroughly Rewritten for the hot C++11 ordinary   totally up to date and recast for the newly published C++11 commonplace, this authoritative and accomplished creation to C++ can assist you to benefit the language quick, and to take advantage of it in glossy, powerful methods.

Operating System Concepts

Continue velocity with the fast-developing global of working structures Open-source working structures, digital machines, and clustered computing are one of the top fields of working structures and networking which are quickly altering. With huge revisions and organizational adjustments, Silberschatz, Galvin, and Gagne’s working method ideas, 8th version continues to be as present and proper as ever, supporting you grasp the basic suggestions of working platforms whereas getting ready your self for today’s rising advancements.

Additional info for Android Native Development Kit Cookbook

Show sample text content

Synchronizing local threads with semaphore at Android NDK we've coated mutex, conditional variables, and reader/writer lock within the past 3 recipes. this is often the final recipe on threads synchronization at Android NDK, and we are going to speak about semaphores. Getting ready... Readers are anticipated to learn during the prior 3 recipes, Synchronizing local threads with mutex at Android NDK, Synchronizing local threads with conditional variables at Android NDK, and Synchronizing local threads with reader/writer locks at Android NDK, sooner than this one. the way to do it... the next steps can assist you create an Android venture that demonstrates the use of pthread reader/writer lock: Create an Android program named NativeThreadsSemaphore. Set the package deal identify as cookbook. chapter6. nativethreadssemaphore. seek advice from the Loading local libraries and registering local equipment recipe in bankruptcy 2, Java local Interface for extra designated directions. Right-click at the undertaking NativeThreadsSemaphore, opt for Android instruments | upload local help. upload a Java dossier named MainActivity. java less than package deal cookbook. chapter6. nativethreadssemaphore. This Java dossier easily quite a bit the local library NativeThreadsSemaphore and calls the local jni_start_threads process. upload records named mylog. h and NativeThreadsSemaphore. cpp below the jni folder. part of the code in NativeThreadsSemaphore. cpp is proven as follows:jni_start_threads creates pNumOfConsumer variety of shopper threads, pNumOfProducer variety of manufacturer threads, and numOfSlots variety of slots: void jni_start_threads(JNIEnv *pEnv, jobject pObj, int pNumOfConsumer, int pNumOfProducer, int numOfSlots) { pthread_t *ths; int i, ret; int *thNum; pthread_mutex_init(&mux, NULL); sem_init(&emptySem, zero, numOfSlots); sem_init(&fullSem, zero, 0); ths = (pthread_t*)malloc(sizeof(pthread_t)*(pNumOfConsumer+pNumOfProducer)); thNum = (int*)malloc(sizeof(int)*(pNumOfConsumer+pNumOfProducer)); for (i = zero; i < pNumOfConsumer + pNumOfProducer; ++i) { thNum[i] = i; if (i < pNumOfConsumer) { ret = pthread_create(&ths[i], NULL, un_by_consumer_thread, (void*)&(thNum[i])); } else { ret = pthread_create(&ths[i], NULL, run_by_producer_thread, (void*)&(thNum[i])); } } for (i = zero; i < pNumOfConsumer+pNumOfProducer; ++i) { ret = pthread_join(ths[i], NULL); } sem_destroy(&emptySem); sem_destroy(&fullSem); pthread_mutex_destroy(&mux); free(thNum); free(ths); } run_by_consumer_thread is the functionality carried out through the shopper thread: void *run_by_consumer_thread(void *arg) { int* threadNum = (int*)arg; int i; for (i = zero; i < four; ++i) { sem_wait(&fullSem); pthread_mutex_lock(&mux); --numOfItems; pthread_mutex_unlock(&mux); sem_post(&emptySem); } go back NULL; } run_by_producer_thread is the functionality completed by means of manufacturer thread: void *run_by_producer_thread(void *arg) { int* threadNum = (int*)arg; int i; for (i = zero; i < four; ++i) { sem_wait(&emptySem); pthread_mutex_lock(&mux); ++numOfItems; pthread_mutex_unlock(&mux); sem_post(&fullSem); } go back NULL; } upload an Android.

Rated 4.51 of 5 – based on 14 votes