当前位置: 动力学知识库 > 问答 > 编程问答 >

How to end call in android in latest devices like 4.2

问题描述:

i m using the below code to end call, but its not happening.

 private void endCallIfBlocked(String callingNumber) {

try {

TelephonyManager tm = (TelephonyManager) getApplicationContext().getSystemService(getApplicationContext().TELEPHONY_SERVICE);

Class c = Class.forName(tm.getClass().getName());

Method m = c.getDeclaredMethod("getITelephony");

m.setAccessible(true);

ITelephony telephonyService = (ITelephony) m.invoke(tm);

telephonyService = (ITelephony) m.invoke(tm);

telephonyService.silenceRinger();

telephonyService.endCall();

}

catch (Exception e) {

e.printStackTrace();

}

}

}

i'm failing to get 'getITelephony' object, it will throw exception. I'm using samsung galaxy s duos phone. How to block calls in this programatically

网友答案:

The getITelephony Reflection method is deprecated as of Android 4+.

So you can't use it on Android 4+.

分享给朋友:
您可能感兴趣的文章:
随机阅读: