Class QtRaaSApplication

java.lang.Object
io.qt.androidautomotive.raas.QtRaaSApplication

public class QtRaaSApplication extends Object
The QtRaaSApplication class serves as the Java-side entry point for embedding a Qt-based Rendering as a Service (RaaS) application into an Android environment.

It is responsible for:

  • Loading the required Qt libraries and native components.
  • Creating a service adapter when running outside of an Android Service context.
  • Forwarding Android Surface and MotionEvent events to the Qt runtime through JNI bindings.

This class is typically instantiated from an Android Service to initialize and manage the Qt runtime environment and its surface-based rendering pipeline.

  • Constructor Summary

    Constructors
    Constructor
    Description
    QtRaaSApplication(android.content.Context context)
    Constructs a QtRaaSApplication instance using the given context, and loads the default Qt main library.
    QtRaaSApplication(android.content.Context context, String mainLibraryName)
    Constructs a new QtRaaSApplication instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    sendTouchEvent(android.view.MotionEvent event, String itemId)
    Forwards a MotionEvent from Android to the corresponding Qt Quick item identified by itemId.
    void
    setSurface(android.view.Surface surface, String itemId)
    Sets a new Android Surface to be associated with a Qt Quick item identified by the given itemId.
    void
    Unsets the surface that was previously associated with the Qt Quick item identified by the given itemId.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • QtRaaSApplication

      public QtRaaSApplication(android.content.Context context, String mainLibraryName)
      Constructs a new QtRaaSApplication instance.

      This constructor initializes and loads the Qt runtime environment using the provided Context and the name of the main Qt library.

      Parameters:
      context - the Android context
      mainLibraryName - the main Qt library name (without prefix/suffix).
    • QtRaaSApplication

      public QtRaaSApplication(android.content.Context context)
      Constructs a QtRaaSApplication instance using the given context, and loads the default Qt main library.
      Parameters:
      context - the Android context or service
  • Method Details

    • setSurface

      public void setSurface(android.view.Surface surface, String itemId)
      Sets a new Android Surface to be associated with a Qt Quick item identified by the given itemId.

      This native method forwards the provided surface handle to the Qt side, where it is mapped to the corresponding item and used for rendering through the QAndroidSurfaceRenderEngine.

      Parameters:
      surface - the Android surface object to associate
      itemId - the id of the Qt Quick item

      Notes:

      • This method is implemented in native (C++) code.
      • If itemId is invalid, this method will fail with a warning.
      • Passing an invalid surface results in undefined behavior.
      • Passing null as the surface is equivalent to calling unsetSurface(String).
      See Also:
    • sendTouchEvent

      public void sendTouchEvent(android.view.MotionEvent event, String itemId)
      Forwards a MotionEvent from Android to the corresponding Qt Quick item identified by itemId.

      This method retrieves and handles touch input forwarding to the Qt side for the specified item.

      Parameters:
      event - the Android touch motion event to send
      itemId - the id of the Qt Quick item that receives the event
    • unsetSurface

      public void unsetSurface(String itemId)
      Unsets the surface that was previously associated with the Qt Quick item identified by the given itemId.

      This method forwards a null surface to the Qt side to stop rendering the item on the surface that was previously associated with it.

      Parameters:
      itemId - the id of the Qt Quick item

      Note: It is crucial to call this method when the surface is about to be destroyed.