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 import容易犯的一个错误
有时,我们需要手动添加一些依赖 b.py import sys sys.path.insert(0,"haha")#引用haha目录下的a文件 当使用时 import a impo ...
- java.lang.IllegalStateException: Failed to load ApplicationContext selenium 异常 解决
WARN <init>, HHH000409: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF R ...
- maven groupID 和 ArtifactID的区别与作用
GroupID是项目组织唯一的标识符,实际对应JAVA的包的结构,是main目录里java的目录结构. ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称.一般Gro ...
- elk架构图
一.概述 笔者为了节约宝贵的服务器资源,把一些可拆分的服务合并在同一台主机.大家可以根据自己的实际业务环境自由拆分,延伸架构.
- 10个很棒的学习Android 开发的网站
1. Android Developers 作为一个Android开发者,官网的资料当然不可错过,从设计,培训,指南,文档,都不应该错过,在以后的学习过程中慢慢理解体会. 2. Android Gui ...
- 【Servlet】Java Serlvet Filter 过滤器
Filter的设计思想Filter是一种AOP(aspect-oriented programming)的设计思想 : 面向切面编程.用于的请求和响应都会走 使用filter的登录案例我们通过一张图片 ...
- 使用Nexus搭建Maven内部服务器
概述 我们在使用maven时,一般通过网络上一些公共的maven仓库来获取jar包,但是有时候会碰到网速比较慢的情况就比较郁闷,Nexus是一个maven的服务器,可以让我们搭建一个本 ...
- iOS 不支持 PWA,那又怎么样?
原文链接http://www.zcfy.cc/article/ios-doesn-8217-t-support-progressive-web-apps-so-what-cloud-four-3400 ...
- iOS UTI
UTI全拼Uniform Type Identifier,直接翻译过来就是统一类型标示符. 这个东西可以实现的功能就是设备之间或者app之间的文件传输. 有兴趣的领个支付宝红包再走, ^_^ 全套相关 ...
- Newtonsoft.Json C# Json序列化和反序列化工具的使用、类型方法大全 C# 算法题系列(二) 各位相加、整数反转、回文数、罗马数字转整数 C# 算法题系列(一) 两数之和、无重复字符的最长子串 DateTime Tips c#发送邮件,可发送多个附件 MVC图片上传详解
Newtonsoft.Json C# Json序列化和反序列化工具的使用.类型方法大全 Newtonsoft.Json Newtonsoft.Json 是.Net平台操作Json的工具,他的介绍就 ...