how to end up my outgoing call.

非 Y 不嫁゛ 提交于 2019-12-05 08:40:23

You may try this:

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

    telephonyService.endCall();

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

you simply abort outgoing call through following code

public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub

    if (intent.getAction()
            .equals("android.intent.action.NEW_OUTGOING_CALL")) {

        phoneNo = intent
                .getStringExtra(Intent.EXTRA_PHONE_NUMBER);

        if (phoneNo.isBlocked(blockNo)) {
            setResultData(null);

        }
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!