autojs横竖屏监听
...小于 1 分钟
autojs横竖屏监听
"ui";
let currentOrientation = context.resources.configuration.orientation
ui.layout(
<vertical gravity="center">
<text text="{{currentOrientation}}" />
</vertical>
)
function onConfigurationChanged(newConfig) {
if (newConfig.orientation != currentOrientation) {
if (newConfig.orientation == 2) {
log("横屏")
} else {
log("竖屏")
}
}
currentOrientation = newConfig.orientation
}
context.registerComponentCallbacks({
onConfigurationChanged: onConfigurationChanged
})