Use biometric authentication, encrypted storage, contacts, calendar and the Android photo picker from HTML. See the AndroidAPI method index for the event format and other method groups.
Pass JSON arguments as strings with JSON.stringify(). Register event listeners before calling the method. When a result contains callbackId, match it to the request.
Biometrics and encrypted storage
Declare USE_BIOMETRIC for authentication or storage protected by biometrics. Store up to 64 KB per value, using keys of 1–64 letters, digits, underscores, dots or hyphens. A change in enrolled biometrics can invalidate a protected key.
| Call | Return or event | Project permission | Usage |
|---|---|---|---|
AndroidAPI.biometricStatus() |
— | USE_BIOMETRIC |
Return JSON with status, strong, deviceCredential and error. Check for available before offering authentication. |
AndroidAPI.biometricAuthenticate(optionsJson, callbackId) |
biometricResult |
USE_BIOMETRIC |
Show the system prompt. Options include required title, subtitle, description, strong and allowDeviceCredential. |
AndroidAPI.secureStore(key, value, optionsJson, callbackId) |
secureStoreResult |
— | Encrypt text with Android Keystore. Set requireBiometric: true in the JSON options to protect reads and writes. |
AndroidAPI.secureLoad(key, optionsJson, callbackId) |
secureLoadResult |
— | Read decrypted value or handle errors such as not_found, key_invalidated and auth_failed. |
AndroidAPI.secureDelete(key) |
— | — | Delete an entry. Returns an empty string on success or an error code. |
const status = JSON.parse(AndroidAPI.biometricStatus());
if (status.status === 'available') {
window.addEventListener('biometricResult', ({ detail }) => {
if (detail.callbackId === 'unlock') console.log(detail.success, detail.error);
});
AndroidAPI.biometricAuthenticate(JSON.stringify({ title: document.title }), 'unlock');
}
Contacts and calendar
Call while the app is visible and declare the relevant read or write permissions. Reads are paged. Reuse the returned IDs for edits, and let the user confirm deletes in the Android shell.
| Call | Return or event | Project permission | Usage |
|---|---|---|---|
AndroidAPI.queryContacts(optionsJson, callbackId) |
contactsResult |
READ_CONTACTS |
Pass search, limit (1–500), offset and optional fields. Read contacts, total and hasMore. |
AndroidAPI.insertContact(json, callbackId) |
contactWriteResult |
WRITE_CONTACTS, READ_CONTACTS |
Create a contact with JSON fields such as name, phones: [{number}] and emails: [{address}]. |
AndroidAPI.updateContact(id, json, callbackId) |
contactWriteResult |
WRITE_CONTACTS, READ_CONTACTS |
Update supplied fields. A supplied phone or email array replaces that list. |
AndroidAPI.deleteContact(id, callbackId) |
contactWriteResult |
WRITE_CONTACTS |
Ask the user to confirm deleting this contact. |
AndroidAPI.listCalendars(callbackId) |
calendarsResult |
READ_CALENDAR |
List available calendars. For inserts choose one with writable: true. |
AndroidAPI.queryEvents(optionsJson, callbackId) |
eventsResult |
READ_CALENDAR |
Pass epoch milliseconds from and to up to a year apart, and optional calendarId, limit (1–500) and offset. Each recurring instance is returned separately. |
AndroidAPI.insertEvent(json, callbackId) |
eventWriteResult |
WRITE_CALENDAR |
Pass calendarId, title, start, end and optional details such as reminders in minutes before the event. |
AndroidAPI.updateEvent(id, json, callbackId) |
eventWriteResult |
WRITE_CALENDAR |
Update supplied fields. If changing time, send both start and end. |
AndroidAPI.deleteEvent(id, callbackId) |
eventWriteResult |
WRITE_CALENDAR |
Ask the user to confirm deleting this event. |
window.addEventListener('calendarsResult', ({ detail }) => {
if (detail.callbackId === 'calendar-list') console.log(detail.calendars, detail.error);
});
AndroidAPI.listCalendars('calendar-list');
Photo picker and media library
pickMedia opens the system picker without Pro. queryMedia and readMediaFile require Pro and the Android permissions for the selected media type. For photo and video queries, partial: true means the user granted access to selected items.
| Call | Return or event | Project permission | Usage |
|---|---|---|---|
AndroidAPI.pickMedia(optionsJson, callbackId) |
mediaPicked |
— | Pick image, video or any. Options include multiple, max (up to 20), maxBytes (up to 16 MB per file) and thumbnail (1–512 px). Read items, skipped and truncated. One pick returns up to 32 MB of files in total. |
AndroidAPI.queryMedia(optionsJson, callbackId) |
mediaResult |
READ_MEDIA_* / READ_EXTERNAL_STORAGE |
Query image, video or audio with limit (1–200), offset, sort and thumbnails. Results include items and hasMore. Call while visible. |
AndroidAPI.readMediaFile(uri, callbackId) |
mediaFileResult |
— | Read base64, mime and size for a URI returned by the current session’s query. |
window.addEventListener('mediaPicked', ({ detail }) => {
if (detail.callbackId === 'pick-photo') console.log(detail.items, detail.error);
});
AndroidAPI.pickMedia(JSON.stringify({ type: 'image', thumbnail: 256 }), 'pick-photo');