这一节,用个简单的例子来调用下之前生成的service.ane

首先建一个flex手机项目

然后在构建路径中把ane引进来

可以看到此ane支持Android平台。

serviceMobile.mxml如下:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
applicationDPI="160"
xmlns:mx="library://ns.adobe.com/flex/mx"
backgroundColor="0"
applicationComplete="init()">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import nav.wenbo.service.ServiceController;
public var sCtrl:ServiceController;
private function init():void {
sCtrl = ServiceController.instance;
} public function startService(event:Event):void
{
sCtrl.startAndriodService();
trace("start");
}
public function stopService(event:Event):void
{
sCtrl.stopAndriodService()
trace("stop");
}
public function sendMessage(event:Event):void
{
sCtrl.setNotification(msginput.text);
trace("init");
}
]]>
</fx:Script>
<s:Button name="init" label="sendMessage" click="sendMessage(event)" y="100">
</s:Button>
<s:Button name="startService" label="startService" click="startService(event)" y="0">
</s:Button>
<s:Button name="stopService" label="stopService" click="stopService(event)" y="50">
</s:Button>
<s:TextInput name="msg" text="输入消息" id="msginput" y="150">
</s:TextInput>
</s:Application>

最后一步,你需要在air -app.xml里配置上service的权限

<android>
<colorDepth>16bit</colorDepth>
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<!--See the Adobe AIR documentation for more information about setting Google Android permissions-->
<!--删除 android.permission.INTERNET 权限将导致无法调试设备上的应用程序-->
<uses-permission android:name="android.permission.INTERNET"/>
......
<application>
<service android:enabled="true" android:exported="true" android:name="nav.wenbo.service.NotificationService" />
</application>
</manifest> ]]></manifestAdditions>
</android>

然后你可以,调试或是装到真机上测试它。这里我装在模拟器上测试它

先占击startService

可以输入一条信息测试

往下拉通知

so, enjoy it!

这里也贴出相关文件

p: 更多的技术交流 wenbocode@126.com

ane下载:  http://files.cnblogs.com/bobolive/service.zip

测试例子+ane下载: http://files.cnblogs.com/bobolive/serviceMobile.zip

最新文章

  1. ubuntu 入门
  2. Linux JDK 安装及卸载 http://www.cnblogs.com/benio/archive/2010/09/14/1825909.html
  3. calculator
  4. CSS Sprite雪碧图应用
  5. USACO1.5Superprime Rid[附带关于素数算法时间测试]
  6. Elven Postman(BST )
  7. zabbix快速安装
  8. HINSTANCE数据类型
  9. SQL Server远程连接(2)
  10. Golang之接口
  11. 接口自动化框架(Pytest+request+Allure)
  12. JavaScript异步并发请求问题
  13. SQL语句汇总(二)——数据修改、数据查询
  14. strcpy函数用法
  15. CodeBlock 快捷键大全
  16. [转]hive metadata 存mysql 注释中文乱码的有关
  17. WPF 动态改变窗口大小
  18. 20145333茹翔 Exp5 利用nmap扫描
  19. jsp的九大内置对象(查询资料,搬砖所得)
  20. web.py 笔记

热门文章

  1. Cocos2d-x——CocosBuilder官方帮助文档翻译1 使用自定义类
  2. [MODx] 4. getResources
  3. 【转】int const A::func()和int A::func() const
  4. web前端开发前景怎么样?
  5. Swift超详细的基础语法-结构体,结构体构造器,定义成员方法, 值类型, 扩充函数
  6. ambassador docker container linking
  7. axel源码学习(0)&mdash;&mdash;程序逻辑
  8. [转]ASP.NET MVC中你必须知道的13个扩展点
  9. matlab——sparse函数和full函数(稀疏矩阵和非稀疏矩阵转换)
  10. #284 div.2 C.Crazy Town