twilio / voice-quickstart-android

Quickstart app for the Voice Android SDK
https://www.twilio.com/docs/api/voice-sdk/android/getting-started
MIT License
184 stars 140 forks source link

How to detect the call state after accept the call from remote user. #544

Closed iyanar1999 closed 10 months ago

iyanar1999 commented 1 year ago
private fun twilioVoiceListener(): Call.Listener {
    return object : Call.Listener {
        override fun onConnectFailure(call: Call, callException: CallException) {
            hideCallNotification(CALL_DISCONNECT_BY_MANUAL)
            binding.tvCall.text = getString(R.string.failure)
            localCall = call
            binding.ivImage.isEnabled = false
        }

        override fun onDisconnected(call: Call, callException: CallException?) {
            hideCallNotification(CALL_DISCONNECT_BY_MANUAL)
            if (CALL_DISCONNECT_BY_MANUAL != 1) {
                binding.tvCall.text = getString(R.string.disconnect)
                localCall = call
                SoundPoolManager.getInstance(requireContext())?.stopRinging()
                disconnect()
                SoundPoolManager.getInstance(requireContext())?.playDisconnect()
                binding.ivImage.isEnabled = true
            }
        }

        override fun onRinging(call: Call) {
            binding.tvCall.text = getString(R.string.ringing)
            localCall = call
            binding.ivImage.isEnabled = true
            SoundPoolManager.getInstance(requireContext())?.playRinging()
        }

        override fun onConnected(call: Call) {
            showCallNotification()
            RpmApp.setActiveCall(call)
            binding.tvCall.text = getString(R.string.connected_new)
            localCall = call
            binding.ivImage.isEnabled = true
            SoundPoolManager.getInstance(requireContext())?.stopRinging()
        }

        override fun onReconnected(call: Call) {
            binding.tvCall.text = getString(R.string.re_connected)
            localCall = call
            binding.ivImage.isEnabled = true
        }

        override fun onReconnecting(call: Call, callException: CallException) {
            binding.tvCall.text = getString(R.string.re_connecting)
            localCall = call
            binding.ivImage.isEnabled = true
            SoundPoolManager.getInstance(requireContext())?.playRinging()
        }

    }

}
afalls-twilio commented 10 months ago

@iyanar1999 Once you receive CallInvite object, call CallInvide.accept(...); passing in the listener you want to receive events with. If the call is accepted, you should then receive an onConnected(..) notification on that newly registered listener, and if any other events occur, they will also be transmitted via that notification object.

Please Note: One can look here as an example.

iyanar1999 commented 10 months ago

Hi Twilio/Voice-Quickstart-Android ,

Thanks for your value update with new features. [image: Twilight IT Solutions.png] https://www.twilightitsolutions.com/

Iyanar D Software Engineer

www.twilightitsolutions.com

[image: fb.png] https://www.facebook.com/TwilightSoftwares [image: tt.png] https://twitter.com/TwilightITSolu1 [image: ln.png] https://www.linkedin.com/company/twilightsolutions/mycompany/ [image: it.png] https://www.instagram.com/twilightitsolutions/

E: @. @.> M: +91 0123456789 A: No.88/2, Villianur Road, Reddiarpalayam, Rev Village, Oulgaret, Puducherry - 605010.

On Thu, Nov 16, 2023 at 5:39 AM afalls-twilio @.***> wrote:

@iyanar1999 https://github.com/iyanar1999 Once you receive CallInvite object, call CallInvide.accept(...); passing in the listener you want to receive events with. If the call is accepted, you should then receive an onConnected(..) notification on that newly registered listener, and if any other events occur, they will also be transmitted via that notification object.

Please Note: One can look here https://github.com/twilio/voice-quickstart-android/blob/293f9f54f62c1a9ed28b9bb41e0b4ad515c0e31f/app/src/standard/java/com/twilio/voice/quickstart/VoiceActivity.java#L542 as an example.

— Reply to this email directly, view it on GitHub https://github.com/twilio/voice-quickstart-android/issues/544#issuecomment-1813496809, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2ZLCHZW2JBDA7QSDOEBMZDYEVKVBAVCNFSM6AAAAAAUQGF56SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJTGQ4TMOBQHE . You are receiving this because you were mentioned.Message ID: @.***>