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

      Fields 
      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
    • Field Detail

      • LAUNCH_URL_KEY

        static final java.lang.String LAUNCH_URL_KEY
        Key used in case the app is launched from an URL with a custom scheme
        See Also:
        Constant Field Values
      • LAUNCH_LOCAL_NOTIFICATION_KEY

        static final java.lang.String LAUNCH_LOCAL_NOTIFICATION_KEY
        Key used in case the app is launched from a local notification
        See Also:
        Constant Field Values
      • LAUNCH_PUSH_NOTIFICATION_KEY

        static final java.lang.String LAUNCH_PUSH_NOTIFICATION_KEY
        Key used in case the app is launched from a push notification
        See Also:
        Constant Field Values
    • Method Detail

      • fire

        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. 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 receive
        value - a String that the service will process when the key is received
      • addListener

        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
        Parameters:
        key - a String that the service is expected to receive
        consumer - the operation that will be accepted
      • removeListener

        void removeListener​(java.lang.String key)
        Removes the listener for the given key
        Parameters:
        key - a String that the service is expected to receive