Class Cefrium
User-Agent
Cefrium identifies itself as Chrome (because it IS Chromium) with a Cefrium product token appended:
Mozilla/5.0 (Linux; Android ...) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/149.0.7827.102 Cefrium/1.0 Mobile Safari/537.36
This ensures full site compatibility while transparently identifying
the client. The User-Agent is configured via CefSettings.user_agent_product
in the native layer. To customize it, use the --user-agent-product
command-line switch before calling initialize():
// Custom product string (replaces the default):
CommandLine.getInstance().appendSwitchWithValue(
"user-agent-product",
"Chrome/149.0.7827.102 MyApp/2.0 Mobile");
Cefrium.initialize(context);
Basic usage
No setup is required: the SDK's CefriumInitProvider performs the
per-process plumbing at app launch, and the engine initializes lazily the first
time a browser is created. Just create one:
CefriumBrowser browser = CefriumBrowser.createWithSurface(activity);
browser.loadUrl("https://example.com");
// When done:
Cefrium.shutdown();
Advanced: to control init timing (e.g. to pass command-line switches before
native init) call initialize(Context) yourself before the first browser.
It is idempotent and self-sufficient — no custom Application needed.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddownloadAndLoadEasyList(android.content.Context context) Download and load EasyList from the internet.static Stringstatic Stringstatic booleanInitialize the Cefrium engine using the application context captured during per-process setup.static booleaninitialize(android.content.Context context) Initialize the Cefrium engine.static booleanstatic intloadAdBlockList(String path) Load ad-blocking filter rules from an EasyList-format file.static voidsetupProcess(android.content.Context context) Run the per-process Chromium setup the browser process needs before native init.static voidshutdown()Shut down the Cefrium engine.
-
Field Details
-
VERSION
Cefrium SDK version.- See Also:
-
CHROMIUM_VERSION
Bundled Chromium engine version (pinned to the build).- See Also:
-
-
Method Details
-
setupProcess
public static void setupProcess(android.content.Context context) Run the per-process Chromium setup the browser process needs before native init. Idempotent and safe to call from any process: it is a no-op in Chromium child processes (sandboxed renderer/GPU/utility), which self-init viaChildProcessService. The SDK'sCefriumInitProvidercalls this automatically at app launch, andinitialize(Context)calls it too, so consumers normally never call it directly.- Parameters:
context- Any context (its application context is used).
-
initialize
public static boolean initialize()Initialize the Cefrium engine using the application context captured during per-process setup. Equivalent toinitialize(Context)but for callers that have no Context handy (e.g. off-screen browser creation). Requires thatsetupProcess(Context)has run — which the SDK'sCefriumInitProviderguarantees at app launch.- Returns:
- true if initialization succeeded.
-
initialize
public static boolean initialize(android.content.Context context) Initialize the Cefrium engine. Safe to call more than once (idempotent) and self-sufficient: it runssetupProcess(Context)itself, so noApplicationboilerplate is required. Must be called on the main thread (the SDK does this lazily on first browser creation).- Parameters:
context- Application context.- Returns:
- true if initialization succeeded.
-
shutdown
public static void shutdown()Shut down the Cefrium engine. Call when the app is finishing. After this call, no Cefrium APIs may be used. -
isInitialized
public static boolean isInitialized()- Returns:
- true if Cefrium has been initialized.
-
getVersion
- Returns:
- the Cefrium SDK version, e.g.
"0.5.0".
-
getChromiumVersion
- Returns:
- the bundled Chromium engine version, e.g.
"149.0.7827.102".
-
loadAdBlockList
Load ad-blocking filter rules from an EasyList-format file. Can be called multiple times to load additional lists.- Parameters:
path- Absolute path to the filter list file.- Returns:
- Number of rules loaded.
-
downloadAndLoadEasyList
public static void downloadAndLoadEasyList(android.content.Context context) Download and load EasyList from the internet. Call from a background thread — performs network I/O.- Parameters:
context- Application context for file storage.
-