I’m creating app for incoming call screen. In my app accept call is working but decline call generate issue to reject call. My app Target sdk version & Compiled sdk version is 30. I’m referring some stack overflow approval question which is work in other app but can’t work that solution in my app.
Please see my code and give me some solution.
public static void disconnectCall() {
try {
Class<?> cls = Class.forName("com.android.internal.telephony.ITelephony");
Class<?> cls2 = cls.getClasses()[0];
Class<?> cls3 = Class.forName("android.os.ServiceManager");
Class<?> cls4 = Class.forName("android.os.ServiceManagerNative");
Method method = cls3.getMethod("getService", String.class);
Method method2 = cls4.getMethod("asInterface", IBinder.class);
new Binder().attachInterface(null, "fake");
cls.getMethod("endCall", new Class[0]).invoke(cls2.getMethod("asInterface", IBinder.class).invoke(null, (IBinder) method.invoke(method2.invoke(null, null), "phone")), new Object[0]);
} catch (Exception e) {
e.printStackTrace();
}
}