jeudi 26 juillet 2018

Android / Java - get TYPE of a hidden class via Reflection

I am trying to use the hidden package manager method installPackage via reflections.

My major problem is that one of its parameters is another hidden class android.content.pm.IPackageInstallObserver. How can I get the TYPE of that class (not an instance of it)?

val cPackageManager = Class.forName("android.content.pm.PackageManager")
val cPackageInstallObserver = Class.forName("android.content.pm.IPackageInstallObserver")

// here I need the IPackageInstallObserver type as a parameter type to look up the method
val installPackageMethod = cPackageManager.getMethod("installPackage", Uri::class.java, cPackageInstallObserver::class.java, Integer.TYPE, String::class.java)

In the way above, cPackageInstallObserver::class.java resolves to only a Class but not the actual type I need.

Does anybody have a solution for that?





Aucun commentaire:

Enregistrer un commentaire