I am trying to send a DTMF tone in an incoming call. For that there is a method playDtmfTone in android.telecom.Call. As it is final class I am unable to create it's object directly.
That is why I am using reflection to get an object. but it throws an exception. Here is my code:
try{
Class<?> c = Class.forName("android.telecom.Call");
Object instance = c.newInstance();
Method m = c.getDeclaredMethod("playDtmfTone", char.class);
m.setAccessible(true);
m.invoke(instance, new Object[]{'1'});
}catch (Exception e){
Log.d("Exception of Reflection", e.getLocalizedMessage());
}
I am getting following msg:
Exception of Reflection: java.lang.Class has no zero argument constructor
I used this idea from this answer.
I am not sure what is going wrong.
Aucun commentaire:
Enregistrer un commentaire