I am currently building an in-app logger utility for Android that uses the Reflection API to log basic data about the called class/method/parameters.
Method.getParameters()
is the call to retrieve an array of parameters for the given method, but this method only works on Android API level 26+. Does anyone know of a workaround that would let me use getParameters()
on API level 25 or below?
Alternatively, if there is a decent workaround for this, that would work too! Thanks in advance! Here is the method I will be updating once I have a fix/workaround in place:
private Parameter[] _retrieveParametersForMethod( Method method ) {
Parameter[] methodParameters;
// getParameters() only works on API level 26+ (Oreo)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return methodParameters = method.getParameters();
} else
return null; // TODO: Find a workaround for pre-API level 26
}
Aucun commentaire:
Enregistrer un commentaire