fun hide()

in azure-communication-ui/calling/src/main/java/com/azure/android/communication/ui/calling/presentation/CallCompositeActivity.kt [308:334]


    fun hide() {
        if (!configuration.enableMultitasking)
            return

        // TODO: should we enter PiP if we are on the setup screen?
        if (configuration.enableSystemPiPWhenMultitasking &&
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
            activity?.packageManager?.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) == true
        ) {
            val params = PictureInPictureParams
                .Builder()
                .setAspectRatio(Rational(1, 1))
                .build()
            var enteredPiPSucceeded = false
            try {
                enteredPiPSucceeded = enterPictureInPictureMode(params)
            } catch (_: Exception) {
                // on some samsung devices(API 26) enterPictureInPictureMode crashes even FEATURE_PICTURE_IN_PICTURE is true
            }
            if (enteredPiPSucceeded)
                reduxStartPipMode()
            else
                activity?.moveTaskToBack(true)
        } else {
            activity?.moveTaskToBack(true)
        }
    }