Android HAL 开发 (4)
来源:互联网 发布:linux 查cpu核心数 编辑:程序博客网 时间:2024/06/03 18:15
http://buaadallas.blog.51cto.com/399160/371560
在上一篇文章中,我们看到了如果在java程序中调用C/C++撰写的函数。而且Android的service已经实现了,下面就要看看应用程序如何调用这个service了,这里用两种方法,我们先介绍简单的第一种直接调用方法。
apps/mokoid/apps/LedClient/src/com/mokoid/LedClient/LedClient.java
package com.mokoid.LedClient; import com.mokoid.server.LedService; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class LedClient extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Call an API on the library. LedService ls = new LedService(); ls.setOn(1); ls.setOff(2); TextView tv = new TextView(this); tv.setText("LED 1 is on. LED 2 is off."); setContentView(tv); } }
上面的代码很简单,直接调用上一篇文章介绍的LedService,然后利用这个service的成员函数setOn和setOff直接操作硬件(通过jni->HAL)。
本文出自 “Mobile and Linux Deve..” 博客,请务必保留此出处http://buaadallas.blog.51cto.com/399160/371560
- Android HAL 开发 (4)
- Android HAL 开发 (4)
- Android HAL 开发 (4)
- Android HAL 开发 (4)
- Android HAL 开发 (4)
- Android HAL 开发 (4)
- Android HAL 开发 (4)
- Android HAL 开发 (1)
- Android HAL 开发 (2)
- Android HAL 开发 (3)
- Android HAL 开发 (5)
- Android HAL 开发 系列
- Android HAL 开发 (1)
- Android HAL 开发 (2)
- Android HAL 开发 (3)
- Android HAL 开发 (5)
- Android HAL 开发 (1)
- Android HAL 开发 (2)
- Android HAL 开发 (3)
- Hibernate核心思想—ORM机制(二)
- 第6章 写一个块设备驱动
- IT技术开发人员35岁之前应该做的十件事
- Hibernate核心思想—ORM机制(三)
- Android HAL 开发 (4)
- Android API Demos学习 - Notification部分
- request.getParameter()和request.getAttribute()
- Oracle客户端配置
- JS
- Spring核心(一)概述
- SQL SERVER2008触发器 inserted deleted
- Spring核心(二)IoC介绍
- ORA-0163: 表 a 无法通过 128(在表空间 abc 中) 扩展,表空间不足