Interface ContinuityBridge
The platform seam of the continuity framework, implemented by ports and returned from
CodenameOneImplementation.getContinuityBridge(). A null bridge -- the base implementation --
leaves saving and restoring state on this device working, because that half is pure
com.codename1.io.Storage, and makes every cross-device capability report itself unsupported.
Two independent capabilities live behind one bridge because a port that has either almost always has both, and an app asks about them separately anyway:
- Continuation advertises what the user is doing so a second device they own can pick it up
while the two are together. On Apple platforms this is an
NSUserActivity; nothing else implements it, and nothing else is expected to. - The synced store is a small key/value store the platform carries between the user's devices without them being near each other.
Everything crosses this boundary as data -- strings and plist-representable maps -- never as live model objects, because on Apple platforms the payload is handed to the operating system and may be delivered to a different device, and a different build of the app, than the one that produced it.
-
Method Summary
Modifier and TypeMethodDescriptionvoidWithdraws the advertised activity.booleanReturns true when this port can advertise the user's current activity to their other devices.booleanReturns true when this port has a key/value store the platform syncs between the user's devices.voidAdvertises the user's current activity, replacing whatever was advertised before.voidsetCallback(ContinuityCallback callback) Installs the framework's inbound seam.syncedStoreGet(String key) Reads a value from the synced store.String[]Every key currently in the synced store, in no particular order.booleansyncedStorePut(String key, String value) Writes a value to the synced store, replacing any previous value for the key.voidsyncedStoreRemove(String key) Removes a key from the synced store.
-
Method Details
-
isContinuationSupported
boolean isContinuationSupported()Returns true when this port can advertise the user's current activity to their other devices. -
publishContinuation
Advertises the user's current activity, replacing whatever was advertised before.
The payload has already been validated as representable and within the platform's size budget by the time it arrives here.
Parameters
activityType: the reverse-DNS type the build declaredtitle: a human readable label the receiving device may show, or nulluserInfo: the state, as strings, numbers, booleans, lists and maps of those
-
clearContinuation
void clearContinuation()Withdraws the advertised activity. Nothing is being continued after this returns. -
isSyncedStoreSupported
boolean isSyncedStoreSupported()Returns true when this port has a key/value store the platform syncs between the user's devices. -
syncedStorePut
Writes a value to the synced store, replacing any previous value for the key.
Returns whether the store took it. A void signature made
SyncedStore.putanswer true whenever a store merely existed, so the documented fallback -- write locally when the synced write fails -- could never run, and a value the store refused was reported saved.Parameters
key: the keyvalue: the value
Returns
true when the store holds the value afterwards
-
syncedStoreGet
-
syncedStoreRemove
Removes a key from the synced store. Removing an absent key does nothing.
Parameters
key: the key
-
syncedStoreKeys
String[] syncedStoreKeys()Every key currently in the synced store, in no particular order. Never null. -
setCallback
Installs the framework's inbound seam. Called once during initialization, before any other method on this bridge; ports must retain it and may call it from any thread.
Parameters
callback: the seam, never null
-