android.net.sip.SipException:无法创建SipSession;网络不可用?

时间:2019-03-19 10:23:39

标签: java android kotlin sip

开发SIP(VOIP)呼叫应用程序。我已经搜索了此问题的解决方案。我找到了一些喜欢的解决方案:

  • 使用targetSdkVersion 9
  • 重新安装应用程序并重新启动设备可以解决问题(发生错误时我使用此方法)

以上两种解决方案都不是一个好的解决方案,也不是用户友好的。 那么,什么是解决SIP问题的最佳解决方案?

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

我已经处理了 SIP库错误

仍然,我正在寻找正确的答案,但是目前,我已经向用户发送了 toast 来重启设备,

  try {
        val intent = Intent()
        intent.action = CALL_ACTION
        val pendingIntent = PendingIntent.getBroadcast(mContext?.applicationContext, 0, intent, Intent.FILL_IN_DATA)
        sipManager?.open(sipProfile, pendingIntent, null)
        sipManager?.setRegistrationListener(sipProfile!!.uriString,
                object : SipRegistrationListener {
                    override fun onRegistering(localProfileUri: String) {
                        Log.e(TAG, "onRegistering $localProfileUri")
                    }

                    override fun onRegistrationDone(localProfileUri: String, expiryTime: Long) {
                        Log.e(TAG, "onRegistrationDone $localProfileUri expiryTime=$expiryTime")
                    }

                    override fun onRegistrationFailed(localProfileUri: String, errorCode: Int, errorMessage: String) {
                        Log.e(TAG, "onRegistrationFailed $localProfileUri $errorMessage $errorCode")
                    }
                })
    } catch (pe: ParseException) {
        Log.e(TAG, pe.message!!)
    } catch (se: SipException) {
        Log.e(TAG, se.message!!)
        if (!sipManager?.isOpened(sipProfile?.uriString)!!) {
            //Just sent a toast to restart the device 
            Toast.makeText(this, "SIP Error - Please Restart Device and Try Again", Toast.LENGTH_SHORT).show()
        } else {
            Toast.makeText(this, se.message, Toast.LENGTH_SHORT).show()
        }
    }