public interface RuntimeArgsService
adding a listener.
Example
Services.get(RuntimeArgsService.class).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:
<activity android:name="com.gluonhq.impl.charm.down.plugins.android.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.impl.charm.down.plugins.android.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.impl.charm.down.plugins.android.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>
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
LAUNCH_LOCAL_NOTIFICATION_KEY |
Key used in case the app is launched from a local notification
|
static java.lang.String |
LAUNCH_PUSH_NOTIFICATION_KEY |
Key used in case the app is launched from a push notification
|
static java.lang.String |
LAUNCH_URL_KEY |
Key used in case the app is launched from an URL with a custom scheme
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addListener(java.lang.String key,
java.util.function.Consumer<java.lang.String> consumer) |
Adds a listener to the given key, like
LAUNCH_LOCAL_NOTIFICATION_KEY or
LAUNCH_URL_KEY, so if those occur, the consumer will accept the provided
String |
void |
fire(java.lang.String key,
java.lang.String value) |
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(java.lang.String key) |
Removes the listener for the given key
|
static final java.lang.String LAUNCH_URL_KEY
static final java.lang.String LAUNCH_LOCAL_NOTIFICATION_KEY
static final java.lang.String LAUNCH_PUSH_NOTIFICATION_KEY
void fire(java.lang.String key,
java.lang.String value)
key - a String that the service is expected to receivevalue - a String that the service will process when the key is receivedvoid addListener(java.lang.String key,
java.util.function.Consumer<java.lang.String> consumer)
LAUNCH_LOCAL_NOTIFICATION_KEY or
LAUNCH_URL_KEY, so if those occur, the consumer will accept the provided
Stringkey - a String that the service is expected to receiveconsumer - the operation that will be acceptedvoid removeListener(java.lang.String key)
key - a String that the service is expected to receive