Android NDK之二:创建NativeActivity
转:http://blog.csdn.net/xiruanliuwei/article/details/7560914
Android NDK为我们提供了两种方式来实现我们的native activity:
1、The native_activity.h header defines the native version of the NativeActivity class. It
contains the callback interface and data structures that you need to create your native
activity. Because the main thread of your application handles the callbacks, your callback
implementations must not be blocking. If they block, you might receive ANR (Application Not
Responding) errors because your main thread will be unresponsive until the callback returns.
Read the comments in the
<ndk_root>/platforms/android-9/arch-arm/usr/include/android/native_activity.h file for
more information.
2、The android_native_app_glue.h file defines a static helper library built on top of the
native_activity.h interface. It spawns another thread to handle things such as callbacks or
input events. This prevents any callbacks from blocking your main thread and adds some
flexibility in how you implement the callbacks, so you might find this programming model a
bit easier to implement.
The <ndk_root>/sources/android/native_app_glue/android_native_app_glue.c
source is also available to you, so you can modify the implementation if you need. Read the
comments in the <ndk_root>/sources/android/native_app_glue/android_native_app_glue.h
file for more information.
通过上面的描述,我们可以发现方式二会简单一些。在使用方式一实现native activity时,
需要注意在实现回调函数时,不要阻塞了main UI thread,否则会出现ANR。而方式二中,
则在一个新线程中创建一个事件循环执行回调函数,因此不会造成main UI thread阻塞。
Android NDK之二:创建NativeActivity的更多相关文章
- Ubuntu 14.04 Android 使用Maven二 创建自己的Mavenproject
依据https://code.google.com/p/maven-android-plugin/wiki/GettingStarted 介绍,有两种方法能够创建Mavenproject. 第一种方法 ...
- Android Studio体验(二)--创建项目和Genymotion试用
上周日已经体验了一把Android Studio顺便没事点了点其他功能,不过还是从自己创建项目开始说吧,首先我们要熟悉Android Studio中的Project 和 Module 两个概念.And ...
- windows系统上安装与使用Android NDK r8d(二)
四. 在eclipse中集成c/c++开发环境 1. 装Eclipse的C/C++环境插件:CDT,这里选择在线安装. 首先登录http://www.eclipse.or ...
- 用Android NDK编译FFmpeg
附(2018-01-06): 有一个将x264及lame等库集成进去了且基于android的ffmpeg的编译方法,地址参见: https://github.com/writing ...
- 三、Android NDK编程预备之Java jni入门创建C/C++共享库
转自: http://www.eoeandroid.com/thread-264971-1-1.html 应网友回复,答应在两天前要出一篇创建C/C++共享库的,但由于清明节假期,跟朋友出去游玩,丢手 ...
- Android NDK入门实例 计算斐波那契数列二生成.so库文件
上一篇文章输生成了jni头文件,里面包含了本地C代码的信息,提供我们引用的C头文件.下面实现本地代码,再用ndk-build编译生成.so库文件.由于编译时要用到make和gcc,这里很多人是通过安装 ...
- Android NDK 开发(二) -- 从Hlello World学起【转】
转载请注明出处:http://blog.csdn.net/allen315410/article/details/41805719 上篇文章讲述了Android NDK开发的一些基本概念,以及NDK ...
- 二、Android NDK编程预备之Java jni入门Hello World
转自: http://www.eoeandroid.com/forum.php?mod=viewthread&tid=264543&fromuid=588695 昨天已经简要介绍了J ...
- android NDK 实用学习(二)-java端对象成员赋值和获取对象成员值
1,关于java端类及接口定义请参考: android NDK 实用学习-获取java端类及其类变量 2,对传过来的参数进行赋值: 对bool类型成员进行赋值 env->SetBooleanF ...
随机推荐
- scipy稀疏矩阵
那些零元素数目远远多于非零元素数目,并且非零元素的分布没有规律的矩阵称为稀疏矩阵(sparse matrix). 不同类型的矩阵有不同的压缩方式,比如对角矩阵只存储对角元素即可.要想充分压缩,就要找到 ...
- iOS 持续集成
iOS 持续集成系列 - 开篇 前言 iOS 开发在经过这几年的野蛮生长之后,慢慢地趋于稳定.无论开发语言是 Objective-C 还是 Swift,工程类型是 Hybird 还是原生,开发思想是 ...
- shell小工具查看Hadoop中System.out输出的日志
#!/bin/bashrm ~/log.logecho "Please Input JobID:"read NAMEmap_log="/home/grid/hadoop- ...
- XSS安全处理
Security.class.php文件 <?php class Security { public $filename_bad_chars = array( '../', '<!--', ...
- 【struts2】预定义拦截器
1)预定义拦截器 Struts2有默认的拦截器配置,也就是说,虽然我们没有主动去配置任何关于拦截器的东西,但是Struts2会使用默认引用的拦截器.由于Struts2的默认拦截器声明和引用都在这个St ...
- 【sql】CHARINDEX
语法:CHARINDEX ( expressionToFind ,expressionToSearch [ , start_location ] ) 参数: 1)expressionToFind 包含 ...
- Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER 解决方案
主要是由于调试的环境中已有一个同名的Provider存在. 解决方法是修改AndroidManifest.xml中的 <provider android:name=".apps.App ...
- MongoDB学习笔记(6)--find
MongoDB 查询文档 MongoDB 查询文档使用 find() 方法. find() 方法以非结构化的方式来显示所有文档. 语法 MongoDB 查询数据的语法格式如下: db.collecti ...
- Oracle 12C -- 删除PDB
删除PDB SQL> select con_id,pdb_name,status from cdb_pdbs; CON_ID PDB_NAME STATUS ---------- ------- ...
- http realtime response 基于http的实时响应方式的演进
http http ajax http polling ajax http long-polling ajax html5 server sent events html5 websocket com ...