5 Ekim 2017 Perşembe

How to terminate a phone call programmatically?

How to terminate a phone call programmatically?

This is the easiest way that I searched and found  it that how to work  in Android

 This is sample code :


public void endCall(Context context) {
   TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
   try {
      Class c = Class.forName(tm.getClass().getName());
      Method m = c.getDeclaredMethod("getITelephony");
      m.setAccessible(true);
      Object telephonyService = m.invoke(tm);

      c = Class.forName(telephonyService.getClass().getName());
      m = c.getDeclaredMethod("endCall");
      m.setAccessible(true);
      m.invoke(telephonyService);

   } catch (Exception e) {
      e.printStackTrace();
   }
}

Hiç yorum yok:

Yorum Gönder