1 / 8

AT91SAM JNI demo project introduction

AT91SAM JNI demo project introduction. JNI Demo Project - Overview. Goal Environment Setup Install JDK 6 Install Android SDK Install Eclipse Install ADT for Eclipse Install Android NDK C Native code in JNI demo project are already built as a shared library. You can run the demo directly.

brendy
Download Presentation

AT91SAM JNI demo project introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AT91SAM JNI demo project introduction

  2. JNI Demo Project - Overview • Goal • Environment Setup • Install JDK 6 • Install Android SDK • Install Eclipse • Install ADT for Eclipse • Install Android NDK • C Native code in JNI demo project are already built as a shared library. You can run the demo directly. • Reference to http://developer.android.com/sdk/installing.html C functions Android UI button LED JNI

  3. JNI Demo Project - C native code • Provide functions to control LED • Open LED device file, then write 1/0 to the file • Works like following command line: • echo 1 > /sys/class/leds/dx/brightness • echo 0 > /sys/class/leds/dx/brightness • JNI prefix • Composed by: • Java • Name space • package com.example.jnidemo; • Class Name • publicclass JNIDemo extends Activity implements • Function name • For example: • Java_com_example_jnidemo_JNIDemo_turnOnLed • Java_com_example_jnidemo_JNIDemo_turnOffLed • Build as a shared library for JAVA to call • Android.mk • include $(BUILD_SHARED_LIBRARY) • Needs Android NDK to build • ndk-build

  4. Create UI buttons Call JNI interface when clicked publicnativeint turnOnLed(); publicnativeint turnOffLed(); Load native library when class is loaded static { System.loadLibrary("led_control"); } JNI Demo Project - Java code

  5. JNI Demo Project - Deploy • Use adb tool to create USB connection • http://www.at91.com/android4sam/bin/view/Android4SAM/UsingAdb • Connect USB cable to EK board (need install USB device driver) • Run adb • ./android update adb • Modify .android\adb_usb.ini • sudo ./adb start-server • Before running JNI demo • chmod 666 /sys/class/leds/dx/brightness • Change the permission for java application can read/write • After reboot system also need run above command • Deploy in the board • ./adb install *.apk • Or using Eclipse IDE • Android SDK, Eclipse and ADT installed • Import this project to work space • Run -> Run As -> Android Application

  6. JNI Demo Project - Running • Running JNI demo • Click “Turn On/Off LED” to turn on/off LED ‘D2’ or ‘D6’. • Debug information will be printed in serial port when logcat is running • Debugging in board • logcat & D2 D6

  7. More information about AT91SAM OS Ecosystem AT91SAM Linux Ecosystem http://www.linux4sam.org AT91SAM Android Ecosystem http://www.at91.com/android4sam AT91SAM WinCE Ecosystem http://www.at91.com/windows4sam AT91SAM community forum http://www.at91.com

More Related