Search code examples
androidcalltelephonymanager

Decline call in android


How to automatically decline the incoming call from app in android after letting the call to ring for 5 secs ?


Solution

  • check this link: Android: Taking complete control of phone(kiosk mode), is it possible? How?

     try{
    
                    TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
                    Class c = Class.forName(manager.getClass().getName());
                    Method m = c.getDeclaredMethod("getITelephony");
                    m.setAccessible(true);
                    ITelephony telephony = (ITelephony)m.invoke(manager);
                    telephony.endCall();
                } catch(Exception e){
                    Log.d("",e.getMessage());
         }