使用反射机制调用buid中的函数接口
来源:互联网 发布:i menu安装软件 编辑:程序博客网 时间:2024/05/01 12:03
package com.xx.xx;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.os.Build;
public class Hitv_IC {
private static String TAG = "Hitv_IC";
public Hitv_IC()
{
}
public static String getBuildMethod(String function) throws Exception
{
String values = null;
Class buildClass = Class.forName("android.os.Build");
Constructor constructor = buildClass.getConstructor();
Object mbuildClass = constructor.newInstance();
Method invokeMethod = buildClass.getMethod(function,null);
values = (String)invokeMethod.invoke(mbuildClass, null);
Log.i(TAG,"getProp values = "+values);
return values;
}
public static void setBuildMethod(String function,String value1,String value2)throws Exception{
int ret = -1;
Class SystemProperties = Class.forName("android.os.Build");
Constructor constructor = SystemProperties.getConstructor();
Object buildMethod = constructor.newInstance();
Method method = SystemProperties.getMethod(function,new Class[] { String.class, String.class });
method.invoke(buildMethod,new Object[]{value1,value2});
int ret = -1;
Class SystemProperties = Class.forName("android.os.Build");
Constructor constructor = SystemProperties.getConstructor();
Object buildMethod = constructor.newInstance();
Method method = SystemProperties.getMethod(function,new Class[] { String.class});
method.invoke(buildMethod,new Object[]{value1});
}
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.os.Build;
public class Hitv_IC {
private static String TAG = "Hitv_IC";
public Hitv_IC()
{
}
public static String getBuildMethod(String function) throws Exception
{
String values = null;
Class buildClass = Class.forName("android.os.Build");
Constructor constructor = buildClass.getConstructor();
Object mbuildClass = constructor.newInstance();
Method invokeMethod = buildClass.getMethod(function,null);
values = (String)invokeMethod.invoke(mbuildClass, null);
Log.i(TAG,"getProp values = "+values);
return values;
}
public static void setBuildMethod(String function,String value1,String value2)throws Exception{
int ret = -1;
Class SystemProperties = Class.forName("android.os.Build");
Constructor constructor = SystemProperties.getConstructor();
Object buildMethod = constructor.newInstance();
Method method = SystemProperties.getMethod(function,new Class[] { String.class, String.class });
method.invoke(buildMethod,new Object[]{value1,value2});
}
int ret = -1;
Class SystemProperties = Class.forName("android.os.Build");
Constructor constructor = SystemProperties.getConstructor();
Object buildMethod = constructor.newInstance();
Method method = SystemProperties.getMethod(function,new Class[] { String.class});
method.invoke(buildMethod,new Object[]{value1});
}
}
使用方法 :
Hitv_IC.setBuildMethod_extern("setxxxx","123456789");//setxxxx为Build.java中的函数 ,123456789是参数
Hitv_IC.getBuildMethod("setxxxx");
0 0
- 使用反射机制调用buid中的函数接口
- 使用反射机制调用构造函数
- java 反射机制调用函数
- java使用反射机制调用方法
- java中的反射机制(getClass函数)
- C#.Net中的反射机制使用入门
- .net中的反射机制的使用
- 如何正确使用Java中的反射机制
- 使用反射通过字符串动态调用函数
- 使用反射调用自身的成员函数
- 使用反射通过字符串动态调用函数
- java 反射调用带回调接口的函数
- java反射机制调用
- 反射机制进行动态调用的两种创建方法实例与hama中的反射机制
- 利用反射机制调用main函数并传递参数
- .NET反射机制去调用一个DLL中的方法
- Java调用private方法—Java中的类反射机制
- Linux操作系统中的系统调用接口函数
- Javascript模块化编程
- Thinking in Java 自学笔记——第二章 一切皆对象
- 编辑文章 - 博客频道 - CSDN.NET
- 自定义TextView实现内容的旋转和偏移
- 正则表达式
- 使用反射机制调用buid中的函数接口
- 使用搜狗输入法实现对代码快捷注释
- 2013 ACM-ICPC长沙赛区全国邀请赛——Travel in time
- ARM协处理器详解
- [转]牛人blog
- 斗地主算法之点选牌
- ubuntu10.04 Git服务器搭建之Gitosis
- store 修改url
- MFC 控件变量绑定为数组变量