Utilities¶
Platform detection and Android context helpers. These are the lowest layer the rest of the package builds on; you usually only need them if you are writing your own native handler or interop code.
Platform detection and shared helpers.
This module is imported early by most other modules, so it avoids
importing platform-specific packages at module level. The detection
results are cached the first time
IS_ANDROID,
IS_IOS, and
IS_WEB are read.
Attributes:
| Name | Type | Description |
|---|---|---|
IS_ANDROID |
bool
|
|
IS_IOS |
bool
|
|
IS_WEB |
bool
|
|
IS_ANDROID
module-attribute
¶
IS_ANDROID: bool = _get_is_android()
True when running inside an Android process.
The flag is computed once at import time, from sys.platform ==
"android" or a successful import of Chaquopy's java module.
IS_IOS
module-attribute
¶
IS_IOS: bool = _get_is_ios()
True when running inside an iOS app bundle.
The flag is computed once at import time, from sys.platform ==
"ios" or the explicit PN_PLATFORM=ios override.
IS_WEB
module-attribute
¶
IS_WEB: bool = _get_is_web()
True when running the browser preview.
Set by pn preview / pn start via PN_PLATFORM=web. Mutually
exclusive with IS_ANDROID / IS_IOS. Off-device unit tests leave
this False and inject a fake backend instead.
IS_NATIVE
module-attribute
¶
IS_NATIVE: bool = IS_ANDROID or IS_IOS or IS_WEB
True whenever the reconciler commits through the bridge.
All three of iOS, Android, and the browser preview render through a bridge transport; only headless tests have no native side at all.
Next steps¶
- Read about the broader runtime in Architecture.