Java 通过反射调用onReportLocation

Java 通过反射调用onReportLocation,java,android,Java,Android,我正在尝试调用onReportLocation()方法: Class ILocationProviderManager=Class.forName(“com.android.internal.location.ILocationProviderManager”); 对象ilpm=ILocationProviderManager.newInstance(); 方法Method=ilpm.getClass().getMethod(“onReportLocation”,Location.class);

我正在尝试调用onReportLocation()方法:

Class ILocationProviderManager=Class.forName(“com.android.internal.location.ILocationProviderManager”);
对象ilpm=ILocationProviderManager.newInstance();
方法Method=ilpm.getClass().getMethod(“onReportLocation”,Location.class);
方法setAccessible(true);
调用(ilpm,位置);
我尝试使用此代码从反射调用它,但我得到:

java.lang.InstantiationException: java.lang.Class<com.android.internal.location.ILocationProviderManager> cannot be instantiated
java.lang.InstanceionException:无法实例化java.lang.Class
如果我使用Method=ILocationProviderManager.getMethod(“onReportLocation”,Location.class);相反,我得到:

java.lang.IllegalArgumentException: Expected receiver of type com.android.internal.location.ILocationProviderManager, but got java.lang.Class<com.android.internal.location.ILocationProviderManager>
java.lang.IllegalArgumentException:应为com.android.internal.location.ILocationProviderManager类型的接收器,但获得了java.lang.Class

我对Java反射相当陌生,你能告诉我我做错了什么吗?还是有其他方法调用onReportLocation?谢谢

请注意该方法上的
@unsupportedapsuage
注释。谢谢你的链接,这个方法是greylisted(在debug中说的),现在我觉得还可以:非SDK接口,目前不受限制,你的应用程序可以使用。但是请注意,这些接口不受支持,可能会在不另行通知的情况下更改。我只需要跟踪任何变化。
java.lang.IllegalArgumentException: Expected receiver of type com.android.internal.location.ILocationProviderManager, but got java.lang.Class<com.android.internal.location.ILocationProviderManager>