Package com.gluonhq.attach.runtimeargs
Interface RuntimeArgsService
- All Known Implementing Classes:
AndroidRuntimeArgsService
,DefaultRuntimeArgsService
,DesktopRuntimeArgsService
,DummyRuntimeArgsService
,IOSRuntimeArgsService
public interface RuntimeArgsService
The runtime args service allows for external events to be fired into Gluon Attach
applications - these events are either provided at startup time as runtime arguments
to the application, or they may be delivered at runtime by external services. Developers
may choose to observe these events by
adding a listener
.
Example
RuntimeArgsService.create().ifPresent(service -> {
service.addListener("ALERT", value -> {
// show alert(value)
});
});
Android Configuration:
To launch the app from a custom URL, like yourScheme://foo.html, register a custom scheme in the AndroidManifest.xml file: Note: these modifications are handled automatically by GluonFX plugin if it is used.
<activity android:name="com.gluonhq.helloandroid.LaunchURLActivity"
android:launchMode="singleTask"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="yourScheme"/>
</intent-filter>
</activity>
To launch the app from a Local Notification, add the following to the
AndroidManifest.xml file:
<activity android:name="javafxports.android.FXActivity"
android:launchMode="singleTop" ...>
</activity>
<activity android:name="com.gluonhq.attach.runtime.android.impl.NotificationActivity"
android:parentActivityName="javafxports.android.FXActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="javafxports.android.FXActivity"/>
</activity>
<receiver android:name="com.gluonhq.attach.runtime.android.impl.AlarmReceiver" />
iOS Configuration:
To launch the app from a custom URL, like yourScheme://foo.html, register a
custom scheme in the plist file:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>your.java.package.YourScheme</string>
<key>CFBundleURLSchemes</key>
<array>
<string>yourScheme</string>
</array>
</dict>
</array>
To launch the app from another app, the latter has to
include in its plist file:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>yourScheme</string>
</array>
- Since:
- 3.1.0
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(String key, Consumer<String> consumer) Adds a listener to the given key, likeLAUNCH_LOCAL_NOTIFICATION_KEY
orLAUNCH_URL_KEY
, so if those occur, the consumer will accept the provided Stringstatic Optional<RuntimeArgsService>
create()
Returns an instance ofRuntimeArgsService
.void
When the app is launched externally, this method is called to identify the key based on the service that is responsible, and the value associated to this key.void
removeListener
(String key) Removes the listener for the given key
-
Field Details
-
LAUNCH_URL_KEY
Key used in case the app is launched from an URL with a custom scheme- See Also:
-
LAUNCH_LOCAL_NOTIFICATION_KEY
Key used in case the app is launched from a local notification- See Also:
-
LAUNCH_PUSH_NOTIFICATION_KEY
Key used in case the app is launched from a push notification- See Also:
-
-
Method Details
-
create
Returns an instance ofRuntimeArgsService
.- Returns:
- An instance of
RuntimeArgsService
.
-
fire
When the app is launched externally, this method is called to identify the key based on the service that is responsible, and the value associated to this key. Typically the developer won't need to call this method for certain services that will launch the app from a Local Notifications or a custom URL.- Parameters:
key
- a String that the service is expected to receivevalue
- a String that the service will process when the key is received
-
addListener
Adds a listener to the given key, likeLAUNCH_LOCAL_NOTIFICATION_KEY
orLAUNCH_URL_KEY
, so if those occur, the consumer will accept the provided String- Parameters:
key
- a String that the service is expected to receiveconsumer
- the operation that will be accepted
-
removeListener
Removes the listener for the given key- Parameters:
key
- a String that the service is expected to receive
-