public final class CrashProtection
- Object
- CrashProtection
Crash protection: captures unhandled exceptions, scrubs PII, persists
each crash to Storage immediately, and uploads to the
Codename One cloud crash service when enabled.
Quick start – call from your Lifecycle.init (NOT from start,
which runs on every resume):
CrashProtection.install();
CrashProtection.setEnabled(true);
install() is idempotent and wires the EDT error handler, the
platform native crash handler, and the native log capture. It also
replays any crash data persisted by the previous run (Java-side
failures buffered in Storage, plus native-layer crash
records written by the platform crash handler before the process
died).
setEnabled defaults to false, so no data leaves the device
until the developer explicitly enables uploads.
Pluggable PII scrubbing: override PiiScrubber and register
your subclass via setScrubber(PiiScrubber) to extend the
default redaction rules. The default scrubber masks the local part
of email addresses (keeping the first three characters and the full
domain) and replaces runs of six or more digits with [num].
The endpoint URL is fixed and cannot be modified by the application. Crash uploads are accepted only for Pro-tier (or higher) accounts for builds produced by the Codename One cloud build server within the last 30 days; out-of-tier or stale builds are silently dropped by the server.
Methods
public static void install() | Installs the crash protection hooks. |
public static boolean isEnabled() | |
public static void setEnabled(boolean enabled) | Enables or disables crash uploads. |
public static void setScrubber(PiiScrubber s) | Replaces the active PII scrubber. |
public static PiiScrubber getScrubber() | |
public static void capture(Throwable t) | Manually report an exception. |
Inherited methods
Method details
install
public static void install()Installs the crash protection hooks. Idempotent: calling more
than once has no effect. Does nothing on the simulator (matches
the legacy Log.bindCrashProtection behaviour) or when crash
protection has been disabled for the current platform via the
codename1.crashProtection.<platform>.enabled build property
(see isPlatformDisabled).
Side effect: any crashes previously persisted to storage but not yet uploaded will be drained in the background if uploads are currently enabled.
isEnabled
public static boolean isEnabled()Returns
true if crash uploads are enabled. Default is false.setEnabled
public static void setEnabled(boolean enabled)setScrubber
public static void setScrubber(PiiScrubber s)PiiScrubber
to extend or replace the default redaction rules.getScrubber
public static PiiScrubber getScrubber()capture
public static void capture(Throwable t)