29import java.lang.reflect.Method;
31import org.jau.lang.ReflectionUtil;
35 private static final Method androidGetPackageInfoVersionNameMethod;
36 private static final Method androidGetPackageInfoVersionCodeMethod;
37 private static final Method androidGetTempRootMethod;
41 final ClassLoader cl =
AndroidUtil.class.getClassLoader();
42 final Class<?> androidAndroidUtilImplClz =
ReflectionUtil.
getClass(
"jau.sys.android.AndroidUtilImpl",
true, cl);
43 androidGetPackageInfoVersionCodeMethod =
ReflectionUtil.
getMethod(androidAndroidUtilImplClz,
"getPackageInfoVersionCode", String.class);
44 androidGetPackageInfoVersionNameMethod =
ReflectionUtil.
getMethod(androidAndroidUtilImplClz,
"getPackageInfoVersionName", String.class);
47 androidGetPackageInfoVersionCodeMethod =
null;
48 androidGetPackageInfoVersionNameMethod =
null;
49 androidGetTempRootMethod =
null;
59 if(
null != androidGetPackageInfoVersionCodeMethod) {
71 if(
null != androidGetPackageInfoVersionNameMethod) {
83 throws RuntimeException {
84 if(
null != androidGetTempRootMethod) {
Utility methods to simplify reflection access.
static final< R > R callStaticMethod(final Method method, final Object ... args)
static final Class<?> getClass(final String clazzName, final boolean initializeClazz, final ClassLoader cl)
Loads and returns the class or null.
static final Method getMethod(final Class<?> clazz, final String methodName, final Class<?> ... argTypes)
static final String getPackageInfoVersionName(final String packageName)
static final int getPackageInfoVersionCode(final String packageName)
static File getTempRoot()
static final boolean isAvailable