zoukankan      html  css  js  c++  java
  • 【译】What is the NDK? (2)

    Sample applications

    The NDK includes sample applications that illustrate how to use native code in your Android applications:

    • hello-jni — a simple application that loads a string from a native method implemented in a shared library and then displays it in the application UI.
    • 从shared library 里 native method 获取一个字符串,显示在程序UI中
    • two-libs — a simple application that loads a shared library dynamically and calls a native method provided by the library. In this case, the method is implemented in a static library imported by the shared library.
    • 动态加载shared library,调用其中的方法。在这个例子里,方法在一个statice library中实现,从shared library导入。
    • san-angeles — a simple application that renders 3D graphics through the native OpenGL ES APIs, while managing activity lifecycle with a GLSurfaceView object.
    • 使用natvie OpenGL ES APIs render 3D图形。
    • hello-gl2 — a simple application that renders a triangle using OpenGL ES 2.0 vertex and fragment shaders.
    • 图形相关
    • hello-neon — a simple application that shows how to use the cpufeatures library to check CPU capabilities at runtime, then use NEON intrinsics if supported by the CPU. Specifically, the application implements two versions of a tiny benchmark for a FIR filter loop, a C version and a NEON-optimized version for devices that support it.
    • CPU相关
    • bitmap-plasma — a simple application that demonstrates how to access the pixel buffers of Android Bitmap objects from native code, and uses this to generate an old-school "plasma" effect.
    • Bitmap相关
    • native-activity — a simple application that demonstrates how to use the native-app-glue static library to create a native activity
    • native activity
    • native-plasma — a version of bitmap-plasma implemented with a native activity.

    For each sample, the NDK includes the corresponding C source code and the necessary Android.mk and Application.mk files. There are located under <ndk>/samples/<name>/ and their source code can be found under <ndk>/samples/<name>/jni/.

    对于每个sample,NDK里提供了相应的C源代码和必要的Android.mk和Application.mk文件。它们位于<ndk>/samples/<name>/,源代码位于<ndk>/samples/<name>/jni/

    You can build the shared libraries for the sample apps by going into <ndk>/samples/<name>/ then calling the ndk-build command. The generated shared libraries will be located under <ndk>/samples/<name>/libs/armeabi/ for (ARMv5TE machine code) and/or<ndk>/samples/<name>/libs/armeabi-v7a/ for (ARMv7 machine code).

    你可以到<ndk>/samples/<name>/ 后调用ndk-build命令来编译shared libraries。生成的shared libraries位于<ndk>/samples/<name>/libs/armeabi/ (ARMv5TE machine code)和<ndk>/samples/<name>/libs/armeabi-v7a/ (ARMv7 machine code).

    Next, build the sample Android applications that use the shared libraries:

    • If you are developing in Eclipse with ADT, use the New Project Wizard to create a new Android project for each sample, using the "Import from Existing Source" option and importing the source from <ndk>/apps/<app_name>/project/. Then, set up an AVD, if necessary, and build/run the application in the emulator.
    • If you are developing with Ant, use the android tool to create the build file for each of the sample projects at<ndk>/apps/<app_name>/project/. Then set up an AVD, if necessary, build your project in the usual way, and run it in the emulator.

    For more information about developing with the Android SDK tools and what you need to do to create, build, and run your applications, see theOverview section for developing on Android.

  • 相关阅读:
    2018/12/21 HDU-2077 汉诺塔IV(递归)
    2018-12-08 acm日常 HDU
    2018/12/12 acm日常 第二周 第六题
    git 添加远程分支,并可以code review.
    zookeeper数据迁移方法
    gem install nokogiri -v '1.6.6.2' 出错
    gem install json -v '1.8.2' error
    gem install bundle 安装失败
    全能型开源远程终端:MobaXterm
    如何写好 Git Commit 信息
  • 原文地址:https://www.cnblogs.com/zz962/p/2209664.html
Copyright © 2011-2022 走看看