0

I am using SensorOrientation to detect when phone is tilted(in landscape) and show another View when in landScape

Activity Implementation

    override fun onResume() {
        super.onResume()
        SensorOrientationChangeNotifier.getInstance(applicationContext).addListener(this)
    }

    override fun onPause() {
        super.onPause()
        SensorOrientationChangeNotifier.getInstance(applicationContext).remove(this)
    }

    override fun onOrientationChange(orientation: Int) {
        if (orientation == 90 || orientation == 270) {
            this.currentFocus?.let { view ->
               val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
               imm?.hideSoftInputFromWindow(view.windowToken, 0)
            }
            binding.cardMemberCard.rootCardView.visibility = View.VISIBLE
            Timber.d("onConfigurationChanged onOrientationChange --> ORIENTATION_LANDSCAPE")
        } else {
            Timber.d("onConfigurationChanged onOrientationChange --> ORIENTATION_PORTRAIT")
            binding.cardMemberCard.rootCardView.visibility = DrawerLayout.GONE
        }
    }

Everything working fine but If any keyboard is open in portrait mode and showing copy cut paste dialog like this

I want to hide this dialog programmatically on orientation change. I don't want to disable it from start like this or that

Initially it should be enable and work but if phone is is in landscape it should hide

Taimoor Khan
  • 541
  • 4
  • 20

0 Answers0