apkplug利用plugin.xml传递自定义属性
2019独角兽企业重金招聘Python工程师标准>>>
plugin.xml文件除了定义插件属性外,开发者也可以根据自己需求添加自定义的属性。
demo源码下载地址 http://git.oschina.net/plug/apkplugBundles/tree/master/PluginDemo
1.配置代码如下
<?xml version="1.0" encoding="UTF-8"?>
<plugin-features
Bundle-Name="plugin文件传参"
Bundle-SymbolicName="com.apkplug.plugindemo"
Bundle-Version="1.0.3"
date="2012.11.28"
Install="false"
provider-name="插件开发商的名称"
provider-url=""
Bundle-Activator="com.apkplug.plugindemo.SimpleBundle"
Bundle-Activity="com.apkplug.plugindemo.MainActivity"
mykey="我是插件自定义的一个参数"
>
</plugin-features>
2.定义com.apkplug.plugindemo.BundleContextFactory 用来保存插件启动时的上下文BundleContext
3.编写 com.apkplug.plugindemo.SimpleBundle implements BundleActivator
public class SimpleBundle implements BundleActivator
{public void start(BundleContext context) throws Exception{System.out.println("Simple Bundle " + context.getBundle().getBundleId()+ " has started.");//保存插件上下文BundleContext 在Activity中使用BundleContextFactory.getInstance().setBundleContext(context);}public void stop(BundleContext context){System.out.println("Simple Bundle " + context.getBundle().getBundleId()+ " has stopped.");}
}
4.在com.apkplug.plugindemo.MainActivity中获取mykey
public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);TextView info=(TextView) this.findViewById(R.id.info);info.setText("plugin.xml自定义key:"+BundleContextFactory.getInstance().getBundleContext().getBundle().getHeaders().get("mykey"));}
}
转载于:https://my.oschina.net/u/138488/blog/228663
apkplug利用plugin.xml传递自定义属性相关推荐
- 解决‘.../rqt_virtual_joy/plugin.xml‘ has no Root Element问题
问题描述 在使用rqt组件时,在终端输入rqt,往往会报下面的错误 Skipped loading plugin with error: XML Document '/opt/ros/melodic/ ...
- 帆软报表插件开发系列之plugin.xml
plugin.xml文件中的所有节点的定义是在fine-core.jar中的com.fr.plugin.xml.PluginElementName中定义的,内容如下: Id("id" ...
- Plugin.xml - Manifest.mf
为了更好的实现动态加载/卸载插件,Eclipse从3.0开始实现OSGI规范,原先在plugin.xml文件里定义的很多内容都被推荐放在manifest.mf文件里,只有<extension&g ...
- ROS 解决pr2_motor_diagnostic_tool/plugin.xml缺失报错
在终端输入rqt_graph报错. [ERROR] [1637216197.121052293]: Skipped loading plugin with error: XML Document '/ ...
- %3c xml 和php冲突,[原创]WEB安全第五章 漏洞学习与利用11 xml实体注入
WEB安全第五章 漏洞学习与利用11 xml实体注入 XXE Injection即XML External Entity Injection,也就是XML外部实体注入攻击.漏洞是在对非安全的外部实体数 ...
- C#中利用事件来传递数据(EventArgs)
前言 前文介绍在GUI编程中的事件,其中说到EventHandler委托类型在声明时,必须有两个参数变量,第一个是object类型,第二个是EventArgs类型. 对于EventArgs类型,有2个 ...
- 利用事件来传递数据(EventArgs)
在GUI编程中的事件,其中说到EventHandler委托类型在声明时,必须有两个参数变量,第一个是object类型,第二个是EventArgs类型. 对于EventArgs类型,有2个作用.当不需要 ...
- Apache CXF Code Generation Maven2 Plugins plugin.xml
文章目录 pom.xml build plugin config Apache CXF Code Generation Maven2 Plugins plugin.xml pom.xml build ...
- Spring中利用applicationContext.xml文件实例化对象和调用方法
Spring中实例化对象和调用方法入门 1.jar包和xml的准备 已上传至百度云盘,链接: https://pan.baidu.com/s/1CY0xQq3GLK06iX7tVLnp3Q 提取码: ...
最新文章
- Elasticsearch-单机部署避坑指南
- linux / scp 详解
- Java源码研究之object to json string debug
- indexOf()方法的使用,截取字符串,字符串截取,切割字符串,split(),join(),Replace()
- 贝叶斯网的R实现( Bayesian networks in R)bnlearn(1)
- arcx函数js_抖音的这个JS,怎么能运行,获取到用户的加载信息
- root用户远程登陆配置
- Java知识系统回顾整理01基础03变量04类型转换
- postman:Tests模块之断言
- Android SDK是什么
- javaIO体系图(2015年9月15日)
- 微习惯养成,互联网产品成败的关键因素
- matlab ga函数详解,matlab遗传算法ga函数
- gin框架下参数的自定义验证小示例
- matlab矢量场数值可视化(动态数值模拟)
- 利用jmeter完成简单的压力测试
- 安装cPanelWHM 技巧
- python列表输出学生姓名学号链表_建立一个链表,记录学生的姓名,学号和成绩,
- Nvidia GPU信息nvidia-smi(Persistence-M持久性内存、Volatile Uncorr. ECC显存错误校正、GPU-Util显卡利用率、Compute M.显卡计算模式)
- 艾永亮:酒店浮沉录,睡不明白的生意经