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 ...
随机推荐
- Python实现:十进制数与(2~16进制数)之间的互相转换
(最开始源于牛客网上的一道编程题 : [编程题] 数制转换) 将X进制转为int十进制的功能函数:(乘X次方各位数的加和法) # 将X进制转为int十进制的功能函数:(乘X次方各位数的加和法) def ...
- linux达人养成计划学习笔记(五)—— 关机和重启命令
一.shutdown 1.格式: shutdown [选项] 时间(now) 选项: -c: 取消前一个关机命令 -h: 关机 -r: 重启 2.程序放入后台执行: shutdown -r 时间 &a ...
- ajax提交出现的问题记载
1.普通ajax提交的时候是没法提交input type=file的,换句话说$_FILES获取不到ajax提交过去的值. 2.ajax提交的时候,设置dataType="json" ...
- C# 使用系统方法发送异步邮件
项目背景: 最近在对几年前的一个项目进行重构,发现发送邮件功能需要一定的时间来处理,而由于发送是同步的因此导致在发送邮件时无法执行后续的操作 实际上发送邮件后只需要将发送结果写入系统日志即可对其他业务 ...
- 恢复oracle中用PLSQL误删除drop掉的表
一.查看回收站中表 select object_name,original_name,partition_name,type,ts_name,createtime,droptime from recy ...
- Spark弹性分布式数据集RDD
RDD(Resilient Distributed Dataset)是Spark的最基本抽象,是对分布式内存的抽象使用,实现了以操作本地集合的方式来操作分布式数据集的抽象实现.RDD是Spark最核心 ...
- Spring Cloud启动应用时指定IP或忽略某张网卡配置
说明:分布式应用部署到服务上,由于服务器可能存在多张网卡,造成IP地址不准的问题. 解决方法: 1.直接添加忽略某张网卡的配置: spring.cloud.inetutils.ignored-inte ...
- python学习笔记——urllib库中的parse
1 urllib.parse urllib 库中包含有如下内容 Package contents error parse request response robotparser 其中urllib.p ...
- Git Note
Git 参考 http://chengshiwen.com/article/head-first-git/ 文件状态 Git目录: (git directory),亦即Git仓库,一般对应项目根目录下 ...
- Selenium2自动化测试实战序言
记得很久之前接触自动化的时候看了一本关于某早期自动化测试工具的书,书名已经记不得了,内容却一直印象深刻.因为那本书根本就是把官方文档有选择性的翻译一遍,对于实际应用来说其作用几乎是零.因此从那时候起我 ...