Home / Demos / Browser APIs
Oorian Core

Browser APIs

View Source

Access browser features from Java: Geolocation, Clipboard, Storage, Notifications, Speech Synthesis, and Fullscreen.

Built with pure Oorian — no external libraries required

Browser APIs Demo

Access browser features from server-side Java

Oorian provides Java wrappers for modern browser APIs, allowing you to access device features like geolocation, clipboard, local storage, notifications, and more—all from server-side Java code. Click the buttons below to try each API.

Geolocation API

Get the user's geographic location using the browser's Geolocation API. Requires user permission.

Click the button to get your location...
java
// Request location (triggers GeolocationEvent)
GeolocationApi.getCurrentPosition(element, GeolocationOptions.highAccuracy());

// Handle response in listener
@Override
public void onEvent(GeolocationEvent event) {
    double lat = event.getLatitude();
    double lng = event.getLongitude();
    double accuracy = event.getAccuracy();
}

Clipboard API

Copy text to the system clipboard. Works in secure contexts (HTTPS).

java
// Copy text to clipboard
ClipboardApi.writeText("Hello from Oorian!");

// Read from clipboard (async, triggers ClipboardEvent)
ClipboardApi.readText(element);

Storage API

Save and retrieve data from the browser's localStorage. Data persists across sessions.

No stored value yet
java
// Save to localStorage
StorageApi.setLocalItem("key", "value");

// Load from localStorage (triggers StorageEvent)
StorageApi.getLocalItem("key", element);

// Handle response in listener
@Override
public void onEvent(StorageEvent event) {
    String value = event.getValue();
}

Notification API

Show desktop notifications. Requires user permission on first use.

Desktop notifications appear outside the browser window and can include a title, body, and icon.

java
// Request permission (required on first use)
NotificationApi.requestPermission(element);

// Show a notification
NotificationApi.show(element, "Title", "Body text");

Speech Synthesis API

Convert text to speech using the browser's speech synthesis engine.

java
// Speak text using default voice
SpeechApi.speak("Hello from Oorian!");

// Stop any current speech
SpeechApi.cancel();

Fullscreen API

Toggle fullscreen mode for the entire page or specific elements.

Click the button to enter fullscreen mode. Press Escape or click again to exit.

java
// Toggle fullscreen for the document
FullscreenApi.toggleFullscreen(element);

// Request fullscreen for a specific element
FullscreenApi.requestFullscreen(myDiv);

// Exit fullscreen
FullscreenApi.exitFullscreen();