Determine if the app is running on a dual-screen device

Use this code to determine whether your app is running on a Surface Duo dual-screen device. You should perform this check before you call APIs from the Surface Duo SDK that interact with the Surface Duo device.

fun isDeviceSurfaceDuo(): Boolean {
    val feature = "com.microsoft.device.display.displaymask"
    val pm = this.packageManager

    return if (pm.hasSystemFeature(feature)) {
        Log.i(TAG, "System has feature: $feature")
        true
    } else {
        Log.w(TAG, "System missing feature: $feature")
        false
    }
}

Caution

You could query the device name, but that is a hardcoded value that is not future-proof; we don't recommend this.