【问题标题】:How to account logout from Csipsimple on click of logout button?如何在单击注销按钮时从 Csipsimple 注销帐户?
【发布时间】:2019-03-18 11:52:08
【问题描述】:

我正在为我的 Voip 应用程序使用 Csipsimple。当我单击注销按钮时,登录屏幕出现,但是当我在注销此号码后拨打电话时,来电即将到来并且通话已连接。

fun disconnect(quit: Boolean, ctx: Context?) {
        try {
            val intent = Intent(SipManager.ACTION_OUTGOING_UNREGISTER)
            intent.putExtra(SipManager.EXTRA_OUTGOING_ACTIVITY, ComponentName(ctx, MainActivity::class.java))
            ctx!!.sendBroadcast(intent)

            val pref = PrefManager(ctx)
            pref.setLoggedIn(false)
            val crMain = ChattingClass()
            crMain.logoutFromChat(this)
            if (quit) {
                // also delete the shared preference when disconnect
                deleteUserFromPref(ctx)
                val finish = Intent(ctx, LoginMainActivity::class.java)
                finish.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
                finish.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
                (ctx as Activity).startActivity(finish)
                (ctx as Activity).finish()
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

我在单击注销按钮时调用此断开连接方法。我正在取消注册 sip 连接并清除共享首选项。

【问题讨论】:

    标签: android voip voip-android


    【解决方案1】:

    在我的 prefProviderWrapper 类中进行一些研究和更改一些代码后,我得到了 CsipSimple 帐户注销的完美解决方案。

    private var prefProviderWrapper: PreferencesProviderWrapper? = null
    
       fun disconnect(quit: Boolean, ctx: Context?) {
            try {
                prefProviderWrapper = PreferencesProviderWrapper(ctx)
                prefProviderWrapper!!.setPreferenceBooleanValue(PreferencesWrapper.HAS_BEEN_QUIT, true)
                val intent = Intent(SipManager.ACTION_OUTGOING_UNREGISTER)
                intent.putExtra(SipManager.EXTRA_OUTGOING_ACTIVITY, ComponentName(ctx, MainActivity::class.java))
                ctx!!.sendBroadcast(intent)
    
                val pref = PrefManager(ctx)
                pref.setLoggedIn(false)
                val crMain = ChattingClass()
                crMain.logoutFromChat(this)
                if (quit) {
                    // also delete the shared preference when disconnect
                    deleteUserFromPref(ctx)
                    val finish = Intent(ctx, LoginMainActivity::class.java)
                    finish.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
                    finish.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
                    (ctx as Activity).startActivity(finish)
                    (ctx as Activity).finish()
                }
            } catch (e: Exception) {
                e.printStackTrace()
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-30
      • 1970-01-01
      • 2020-06-10
      • 2018-08-03
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多