Android How Do To Reflection In Android.telecom.call Class
I want to block a phone call and i try using reflection android.telecom.Call class with following code but this class does not has constructor . try { Class c = Class.forNa
Solution 1:
- You need to instantiate Class Call because you'll use the instance as a target for you method invocation.
- The method getMethod ignores non-public method. You should use getDeclaredMethod to find your private method.
Your code may look like this:
try
{
Class<?> c = Class.forName("android.telecom.Call");
Object instance = c.newInstance();
Method m = c.getDeclaredMethod("disconnect");
m.setAccessible(true);
m.invoke(instance, new Object[] {});
}
catch (Exception e)
{
Log.e("Exception of Reflection", e.getLocalizedMessage());
}
Post a Comment for "Android How Do To Reflection In Android.telecom.call Class"