[Code] Android设备上如何挂断电话

如果你想在安卓设备上挂断电话,那么以下的代码可以实现此功能。

      public static void endCall(Context context) throws SecurityException,  
                NoSuchMethodException, IllegalArgumentException,  
                IllegalAccessException, InvocationTargetException {  
           Method methodGetITelephony = TelephonyManager.class.getDeclaredMethod("getITelephony", (Class[]) null);  
           methodGetITelephony.setAccessible(true);  
           TelephonyManager tmg = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);  
           Object itelephony = methodGetITelephony.invoke(tmg, (Object[]) null);  
           Method methodEndCall = itelephony.getClass().getMethod("endCall",new Class[] {});  
           methodEndCall.invoke(itelephony, new Object[] {});  
      }// end of method