1

当一个拨出呼叫事件触发时,经过一段时间的呼叫发送 DTMF 音,但当发送 DTMF 音时,先前的呼叫将保持并生成新的呼叫,并在 android 中生成 3 路呼叫。
我能做什么调用不生成 3 路代码?

发送DTMF的代码是:

ToneGenerator tone = new ToneGenerator(AudioManager.STREAM_DTMF,ToneGenerator.MAX_VOLUME >> 1);
tone.startTone(ToneGenerator.TONE_DTMF_1);
tone.startTone(ToneGenerator.TONE_DTMF_2);
tone.startTone(ToneGenerator.TONE_DTMF_3);
tone.startTone(ToneGenerator.TONE_DTMF_4);
tone.startTone(ToneGenerator.TONE_DTMF_5);
tone.startTone(ToneGenerator.TONE_DTMF_6);
tone.startTone(ToneGenerator.TONE_DTMF_7);
tone.startTone(ToneGenerator.TONE_DTMF_8);
tone.startTone(ToneGenerator.TONE_DTMF_9);
tone.startTone(ToneGenerator.TONE_DTMF_P);
tone.startTone(ToneGenerator.TONE_DTMF_S);

tone.stopTone();

concatenate_tonevalue = ("tel://");

for (i = 0; i < j; i++) {

        value = String.valueOf(param.charAt(i));

        try {
            parsetonevalue = Integer.parseInt(value);
        } catch (Exception e) {
            // TODO: handle exception
        }

        tonea = ToneGenerator.TONE_DTMF_0;
        toneb = ToneGenerator.TONE_DTMF_1;
        tonec = ToneGenerator.TONE_DTMF_2;
        toned = ToneGenerator.TONE_DTMF_3;
        tonee = ToneGenerator.TONE_DTMF_4;
        tonef = ToneGenerator.TONE_DTMF_5;
        toneg = ToneGenerator.TONE_DTMF_6;
        toneh = ToneGenerator.TONE_DTMF_7;
        tonei = ToneGenerator.TONE_DTMF_8;
        tonej = ToneGenerator.TONE_DTMF_9;
        tonek = ToneGenerator.TONE_DTMF_P;
        tonel = ToneGenerator.TONE_DTMF_S;

        /* compare dialed value with tone generator value */

        if (parsetonevalue == tonea) {

            concatenate_tonevalue += String.valueOf(tonea) + ",";

        } else if (parsetonevalue == toneb) {

            concatenate_tonevalue += String.valueOf(toneb) + ",";

        } else if (parsetonevalue == tonec) {

            concatenate_tonevalue += String.valueOf(tonec) + ",";

        } else if (parsetonevalue == toned) {

            concatenate_tonevalue += String.valueOf(toned) + ",";

        } else if (parsetonevalue == tonee) {

            concatenate_tonevalue += String.valueOf(tonee) + ",";

        } else if (parsetonevalue == tonef) {

            concatenate_tonevalue += String.valueOf(tonef) + ",";

        } else if (parsetonevalue == toneg) {

            concatenate_tonevalue += String.valueOf(toneg) + ",";

        } else if (parsetonevalue == toneh) {

            concatenate_tonevalue += String.valueOf(toneh) + ",";

        } else if (parsetonevalue == tonei) {

            concatenate_tonevalue += String.valueOf(tonei) + ",";

        } else if (parsetonevalue == tonej) {

            concatenate_tonevalue += String.valueOf(tonej) + ",";

        } else if (parsetonevalue == tonek) {

            concatenate_tonevalue += String.valueOf(tonek) + ",";

        } else if (parsetonevalue == tonel) {

            concatenate_tonevalue += String.valueOf(tonel) + ",";

        }
    }

    Uri uri = Uri.parse(concatenate_tonevalue + ToneGenerator.TONE_DTMF_P);

    MyActivity activity = new MyActivity();
    activity.finish();


    Intent i = new Intent(Intent.ACTION_CALL, uri);
            startActivity(i);

    return false;
}
4

0 回答 0