1

I am using Csipsimple for my Voip app. when i am click logout button the login screen comes but when i am call after logout on this number the incoming call is coming and call has been connected.

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()
        }
    }

I am call this disconnect method on click of logout button. i am unregister the sip connection and clear a shared preference.

Mayur
  • 725
  • 2
  • 13

1 Answers1

0

After Some Research and Changes a little bit code in my prefProviderWrapper class, i am getting the perfect solution for CsipSimple Account logout.

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()
        }
Mayur
  • 725
  • 2
  • 13