【译】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.

转载于:https://www.cnblogs.com/zz962/archive/2011/10/13/2209664.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值