现在的位置: 首页 > 综合 > 正文

android插件化-监听apkplug插件安装/卸载状态-05

2018年02月23日 ⁄ 综合 ⁄ 共 618字 ⁄ 字号 评论关闭

可下载最新的apkplugdemo源码http://git.oschina.net/plug/apkplugDemos

    有时我们需要以事件的形式监听插件的安装/卸载状态等信息,如插件列表更新等场合。apkplug框架提供这样的功能并且实现简单

01 public void ListenerBundleEvent(){
02  frame.getSystemBundleContext()
03 .addBundleListener(
04     new SynchronousBundleListener(){
05         public void bundleChanged(BundleEvent
event) {
06         //插件状态改变事件
07         event.getType()
;
//事件类型
08         event.getBundle();//发生事件的插件Bundle
09                          
10              
11     });
12 }

事件类型

      BundleEvent.INSTALLED;     //插件安装事件

      BundleEvent.STOPPED;       //插件停止事件

      BundleEvent.UNINSTALLED; //插件卸载事件

      BundleEvent.UPDATED;      //插件更新事件

抱歉!评论已关闭.