No ringing event on incoming calls

拈花ヽ惹草 提交于 2019-12-05 09:09:04
Mad Potato

There is an error in the source code of SipAudioCall class.

To work around this issue:

incomingCall = wtActivity.manager.takeAudioCall(intent, null);
incomingCall.setListener(listener, true);

I have implemented same scenario to accept or reject incoming call in sip demo. Create your own Activity (IncomingGui.java) with two buttons Accept and Reject. In BroadcastReciever class call your Activity(IncomingGui.java) on incoming call event.

        WalkieTalkieActivity wtActivity = (WalkieTalkieActivity) context;
        incomingCall = wtActivity.manager.takeAudioCall(intent, listener);
        showIncomingCallGui(intent, context); 
        wtActivity.call = incomingCall;

Then define following methods in BroadcastReciever class

    public void showIncomingCallGui(Intent intent,Context context) {

       Intent incomingCall=new Intent(context,IncomingCallGui.class);
       context.startActivity(incomingCall);
    }

public static void answerIncomingCall(){

    try {
            incomingCall.answerCall(30);
            incomingCall.startAudio();
            incomingCall.setSpeakerMode(true);

                if (incomingCall.isMuted()) {
                incomingCall.toggleMute();

            }
    }

    catch(Exception e){

        System.out.println(e.toString());
    }

}

public static void rejectIncomingCall(){

    try {
            if (incomingCall !=null) {

                incomingCall.endCall();
                incomingCall.close();
            }

    }
            catch(Exception e){

        System.out.println(e.toString());
    }

Then in IncomingGui.java define following methods behind "Accept" and "Reject" Buttons. Now on incoming call you will have your own incoming call activity to accept or reject call.

    public void onCallAcceptButton(View view){
    IncomingCallReceiver.answerIncomingCall();
}

    public void onCallRejectButton(View view){
    IncomingCallReceiver.rejectIncomingCall();
    this.finish();

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