Skip to main content

isUnfolded

Description

Returns whether a foldable device is currently unfolded.

It returns true only when getFoldableState() is "unfolded". When the state cannot be determined ("unknown"), it returns false.

Parameters

None

Returns

TypeDescription
booltrue if the foldable device is unfolded, false if it is folded or the state is unknown

Notes

  • This works on foldable Android devices only. On other devices it always returns false.
  • Use the onFoldableStateChanged callback to receive fold state change events.
  • Since "unknown" also returns false, use getFoldableState() when you need a more detailed state.

Example

// Check whether the device is unfolded
if ($app.isUnfolded()) {
// Apply a layout suited to the unfolded screen
$page.setVar("layoutMode", "wide");
} else {
$page.setVar("layoutMode", "compact");
}

// React in real time to state changes
$vm.onFoldableStateChanged = function(state, isFolded, isUnfolded) {
if (isUnfolded) {
console.log("기기가 펼쳐졌습니다.");
}
};
  • $app.getFoldableState() — returns the current fold state as a string ("folded" / "unfolded" / "unknown")
  • $vm.onFoldableStateChanged(state, isFolded, isUnfolded) — fold state change event