我下载了NDK,里面sapmles目录下有个“native-activity”的demo,请问这个demo编译后如何安装到android手机上,“hello-jni”这个demo我安装运行是可以的,但它是通过Java代码调用的,我想问下能否不通过JNI,直接将纯C++应用部署的手机上运行,求步骤,先说声谢谢!
另外,“native-activity”这个demo的代码中有个名为void android_main(struct android_app* state) 的函数,注释说,这个是程序入口,请问这个是不是android上的main函数,程序要怎么编译或配置后才能调用这个入口:
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main(struct android_app* state) {

解决方案 »

  1.   

    应该只是针对后台进程,比如android系统中一些守护进程,rild等
      

  2.   

    喔,那如何将不通过JNI直接发布C++应用呢?
      

  3.   

    android本身就是java开发的,C++来直接发布应用,不太可能吧,都是通过JNI来调用C++写好的函数库!!
      

  4.   

    看“native-activity”就够了,
    是在AndroiodManifest.xml来制定native activity的
      

  5.   

    用opengl做界面的话应该就和java没啥关系了。
      

  6.   

    对的,我是需要用OpenGLES,请问如何不用编写Java代码,直接部署自己的应用
      

  7.   

    其实写一点点java也不会死人吧
      

  8.   

    NDK文档 OVERVIEW中说II. Android NDK Non-Goals:
    --------------------------The NDK is *not* a good way to write generic native code that runs on Android
    devices. In particular, your applications should still be written in the Java
    programming language, handle Android system events appropriately to avoid the
    "Application Not Responding" dialog or deal with the Android application
    life-cycle.NDK不是写运行在Android设备上的通用native代码的好方法.特别是您的程序应该仍用Java语言来写,处理安卓系统事件来避免ANR错误或者处理Android应用生命周期
      

  9.   

    Note however that is is possible to write a sophisticated application in
    native code with a small "application wrapper" used to start/stop it
    appropriately.
    注意,但你可以用native代码写一个带有"应用外壳"复杂的程序,这个外壳用以恰当的开始/停止应用 
      

  10.   

    嗯,我再多看下NDK的docs。
    docs目录下的NATIVE-ACTIVITY.HTML貌似说明了如何开发和部署纯C++应用,我再研究下
      

  11.   

    搞定了,问题解决了。其实NDK那个native-active的demo可以直接编译后部署,是一个纯C++的OpenGLES应用例子,最开始我修改了AndroidManifest.xml这个配置文件,改错了导致无法正常安装应用,其实配置都不用改,用NDK make以后,再用eclipse编译成apk,就可以直接安装运行了。谢谢各位!
      

  12.   

    LZ可以讲一下AndroidManifest.xml文件里面写的和别的不一样的地方不,看不懂