I try to use reflect to call the android.app.ActivityThread.currentActivityThread()
function
val currentActivityThread = invoke_static_method("android.app.ActivityThread",
"currentActivityThread",
arrayOf<Class<*>>(),
arrayOf<Any>())
fun invoke_static_method(className: String,
methodName: String,
pareTypes: Array<Class<*>>,
pareValues: Array<Any>): Any?{
try {
val objClass: Class<*> = Class.forName(className)
val method = objClass.getMethod(methodName,*pareTypes)
Log.d("dump",method.toString()+pareValues.size)
return method.invoke(null,pareValues)
}catch (e: Exception){
Log.d("dump",e.toString())
e.printStackTrace()
}
return null
}
From the log,I've alrady got this method
D/dump: public static android.app.ActivityThread android.app.ActivityThread.currentActivityThread()0
D/dump: java.lang.IllegalArgumentException: Wrong number of arguments; expected 0, got 1
I don't know why invoke throws out IllegalArgumentException since pareValues
has been correctly initialized
Thx for any help
Aucun commentaire:
Enregistrer un commentaire