getFoldableState
Description
Returns the name of the current fold state of a foldable device as a string.
Use it when you need more detailed state information than isUnfolded() or isFolded gives you.
Parameters
None
Returns
| Type | Value | Description |
|---|---|---|
| String | "folded" | The device is folded |
| String | "unfolded" | The device is unfolded |
| String | "unknown" | The state cannot be detected (including regular devices) |
Notes
- This feature works on foldable Android devices only.
- ⚠️ Caution: On regular devices — desktop included — it returns
"folded"rather than"unknown". Internally it falls back tofoldedwhen nodisplayFeaturesare present, which is a known issue. - If you only need a simple
true/falsecheck, useisUnfolded().
Example
// Check the current fold state string
var state = $app.getFoldableState();
console.log("폴드 상태:", state); // "folded", "unfolded", "unknown"
// Branch on each state
switch (state) {
case "unfolded":
console.log("펼쳐진 상태 - 와이드 레이아웃");
break;
case "folded":
console.log("접힌 상태 - 컴팩트 레이아웃");
break;
default:
console.log("일반 기기 또는 상태 미감지");
}
Related
$app.isUnfolded()— Returns whether the device is unfolded as abool$vm.onFoldableStateChanged(state, isFolded, isUnfolded)— Fold state change event