当检查某个条件后来电是否满足我是否想要自动参加该电话时,否则应该拒绝。任何人都可以通过我的应用程序帮助我如何参加或拒绝来电。 我试图使用下面的代码,但我无法导入包“com.android.internal.telephony.ITelephony”
private void getTeleService() {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
try {
// Java reflection to gain access to TelephonyManager's
// ITelephony getter
Log.v(TAG, "Get getTeleService...");
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG,
"FATAL ERROR: could not connect to telephony subsystem");
Log.e(TAG, "Exception object: " + e);
}
}
telephonyService.answerRingingCall();
telephonyService.endCall();