简体   繁体   English

如何从我的Android应用程序拨打电话?

[英]How to finish call phone from my android app?

I have my Android app and I want to to finish call phone from my application. 我有我的Android应用程序,并且想完成我应用程序中的通话。 How I can to do it? 我该怎么做?

you need to add this file ITelephony.aidl then use this method to end the call: 您需要添加此文件ITelephony.aidl,然后使用此方法结束通话:

public static void callReject(Context context) throws Exception{
        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());
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM