通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(五)
来源:互联网 发布:股市时间窗口算法 编辑:程序博客网 时间:2024/06/05 03:17
http://www.cnblogs.com/bobolive/p/3203797.html
这一节,用个简单的例子来调用下之前生成的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
0 0
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(五)
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(二)
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(一)
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(一)
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(二)
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(三)
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(四)
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(二)
- Adobe Native Extension(ANE)-Actionscript通过语音来控制你的android应用-Air for android
- AIR Native Extension的使用(Android)一 : 打包ane
- air native extension java代码在ane文件解压后
- android通过服务实现消息推送
- android通过服务实现消息推送
- android通过服务实现消息推送
- 通过服务启动消息通知
- AIR中不使用ANE实现IOS消息推送
- AIR Native Extension的使用(Android)二 : Flex mobile项目中使用ane
- WindowsPhone消息推送服务
- IPv6 Neighbor Discovery
- socket编程基础2(socket API函数介绍)
- pentaho data-integration CE 5.0.1-stable ( kettle ) 使用 mysql 创建资源库 (repository )
- 用 Asterisk 实现CallBack功能
- Google Map API
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(五)
- Hibernate createSQLQuery 的用法 操作函数结果
- OCP-1Z0-053-200题-56题-633
- css内容垂直居中
- java中ArrayList 、LinkList区别
- linux下文件(夹)的压缩和解压缩
- cocos2dx 3.0 微信打飞机--003
- 面向对象语言的多分派、单分派、双重分派
- 200多个js技巧代码