当前位置: 编程技术>移动开发
本页文章导读:
▪Activity其间调用成员方法 Activity之间调用成员方法
先贴代码吧,没什么可说的
public void callMethod()
{
try {
//获取环境变量
Context ctx = createPackageContext("com.forhope.zhang", Context.CONTEXT_IGNORE_SECURITY|CONTEXT_INCLUDE_CODE);
.........
▪ The Hit List 破译 The Hit List 破解
断网注册,完全破解
Name: Jaime Creixems
SN: DBHTN-5WHVB-V9GGA-MA77S
......
▪ Sinatra:Base#helpers Sinatra::Base#helpers
1185 public 1186 # Makes the methods defined in the block and in the Modules given 1187 # in `extensions` available to the handlers and templates 1188 def hel.........
[1]Activity其间调用成员方法
来源: 互联网 发布时间: 2014-02-18
Activity之间调用成员方法
先贴代码吧,没什么可说的
嗯,谢谢提醒
先贴代码吧,没什么可说的
public void callMethod()
{
try {
//获取环境变量
Context ctx = createPackageContext("com.forhope.zhang", Context.CONTEXT_IGNORE_SECURITY|CONTEXT_INCLUDE_CODE);
//载入这个类
Class clazz = ctx.getClassLoader().loadClass("com.forhope.zhang.MainActivity");
//新建一个实例
Object owner = clazz.newInstance();
//调用方法,传入参数,得到结果
clazz.getMethod("print", String.class).invoke(owner, "fuck");
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
1 楼
龙哥IT
2011-10-09
境 干嘛用的?
2 楼
read_act
2011-12-14
提醒大家 , 这个方法虽然是可以调用到, 但却是新建了一个Activity实例再调用method, 所以,成员变量都是null !!
3 楼
蜗牛/
2011-12-14
read_act 写道
提醒大家 , 这个方法虽然是可以调用到, 但却是新建了一个Activity实例再调用method, 所以,成员变量都是null !!
嗯,谢谢提醒
4 楼
龙哥IT
2012-01-11
[2] The Hit List 破译
来源: 互联网 发布时间: 2014-02-18
The Hit List 破解
断网注册,完全破解
Name: Jaime Creixems
SN: DBHTN-5WHVB-V9GGA-MA77S
[3] Sinatra:Base#helpers
来源: 互联网 发布时间: 2014-02-18
Sinatra::Base#helpers
1185 public
1186 # Makes the methods defined in the block and in the Modules given
1187 # in `extensions` available to the handlers and templates
1188 def helpers(*extensions, &block)
=> 1189 class_eval(&block) if block_given?
1190 include(*extensions) if extensions.any?
1191 end
1185 public
1186 # Makes the methods defined in the block and in the Modules given
1187 # in `extensions` available to the handlers and templates
1188 def helpers(*extensions, &block)
=> 1189 class_eval(&block) if block_given?
1190 include(*extensions) if extensions.any?
1191 end
最新技术文章: