Class GeckoRuntime

Object
org.mozilla.geckoview.GeckoRuntime
All Implemented Interfaces:
Parcelable

public final class GeckoRuntime extends Object implements Parcelable
  • Field Details

  • Method Details

    • getDefault

      @UiThread @NonNull public static GeckoRuntime getDefault(@NonNull Context context)
      Get the default runtime for the given context. This will create and initialize the runtime with the default settings.

      Note: Only use this for session-less apps. For regular apps, use create() instead.

      Parameters:
      context - An application context for the default runtime.
      Returns:
      The (static) default runtime for the context.
    • attachTo

      @UiThread public void attachTo(@NonNull Context context)
      Attach the runtime to the given context.
      Parameters:
      context - The new context to attach to.
    • create

      @UiThread @NonNull public static GeckoRuntime create(@NonNull Context context)
      Create a new runtime with default settings and attach it to the given context.

      Create will throw if there is already an active Gecko instance running, to prevent that, bind the runtime to the process lifetime instead of the activity lifetime.

      Parameters:
      context - The context of the runtime.
      Returns:
      An initialized runtime.
    • getWebExtensionController

      @UiThread @NonNull public WebExtensionController getWebExtensionController()
      Returns a WebExtensionController for this GeckoRuntime.
      Returns:
      an instance of WebExtensionController.
    • getContentBlockingController

      @UiThread @NonNull public ContentBlockingController getContentBlockingController()
      Returns the ContentBlockingController for this GeckoRuntime.
      Returns:
      An instance of ContentBlockingController.
    • getProfilerController

      @UiThread @NonNull public ProfilerController getProfilerController()
      Returns a ProfilerController for this GeckoRuntime.
      Returns:
      an instance of ProfilerController.
    • create

      @UiThread @NonNull public static GeckoRuntime create(@NonNull Context context, @NonNull GeckoRuntimeSettings settings)
      Create a new runtime with the given settings and attach it to the given context.

      Create will throw if there is already an active Gecko instance running, to prevent that, bind the runtime to the process lifetime instead of the activity lifetime.

      Parameters:
      context - The context of the runtime.
      settings - The settings for the runtime.
      Returns:
      An initialized runtime.
    • shutdown

      @AnyThread public void shutdown()
      Shutdown the runtime. This will invalidate all attached sessions.
    • setDelegate

      @UiThread public void setDelegate(@Nullable GeckoRuntime.Delegate delegate)
      Set a delegate for receiving callbacks relevant to to this GeckoRuntime.
      Parameters:
      delegate - an implementation of GeckoRuntime.Delegate.
    • getDelegate

      @UiThread @Nullable public GeckoRuntime.Delegate getDelegate()
      Returns the current delegate, if any.
      Returns:
      an instance of GeckoRuntime.Delegate or null if no delegate has been set.
    • setAutocompleteStorageDelegate

      @UiThread public void setAutocompleteStorageDelegate(@Nullable Autocomplete.StorageDelegate delegate)
      Set the Autocomplete.StorageDelegate instance on this runtime. This delegate is required for handling autocomplete storage requests.
      Parameters:
      delegate - The Autocomplete.StorageDelegate handling autocomplete storage requests.
    • getAutocompleteStorageDelegate

      @UiThread @Nullable public Autocomplete.StorageDelegate getAutocompleteStorageDelegate()
      Get the Autocomplete.StorageDelegate instance set on this runtime.
      Returns:
      The Autocomplete.StorageDelegate set on this runtime.
    • setServiceWorkerDelegate

      @UiThread public void setServiceWorkerDelegate(@Nullable GeckoRuntime.ServiceWorkerDelegate serviceWorkerDelegate)
      Sets the GeckoRuntime.ServiceWorkerDelegate to be used for Service Worker requests.
      Parameters:
      serviceWorkerDelegate - An instance of GeckoRuntime.ServiceWorkerDelegate.
      See Also:
    • getServiceWorkerDelegate

      @UiThread @Nullable public GeckoRuntime.ServiceWorkerDelegate getServiceWorkerDelegate()
      Gets the GeckoRuntime.ServiceWorkerDelegate to be used for Service Worker requests.
      Returns:
      the GeckoRuntime.ServiceWorkerDelegate instance set by setServiceWorkerDelegate(org.mozilla.geckoview.GeckoRuntime.ServiceWorkerDelegate)
    • setWebNotificationDelegate

      @UiThread public void setWebNotificationDelegate(@Nullable WebNotificationDelegate delegate)
      Sets the delegate to be used for handling Web Notifications.
      Parameters:
      delegate - An instance of WebNotificationDelegate.
      See Also:
    • getWebNotificationDelegate

      @UiThread @Nullable public WebNotificationDelegate getWebNotificationDelegate()
      Returns the current WebNotificationDelegate, if any
      Returns:
      an instance of WebNotificationDelegate or null if no delegate has been set
    • setActivityDelegate

      @UiThread public void setActivityDelegate(@Nullable GeckoRuntime.ActivityDelegate delegate)
      Set the GeckoRuntime.ActivityDelegate instance on this runtime. This delegate is used to provide GeckoView support for launching external activities and receiving results from those activities.
      Parameters:
      delegate - The GeckoRuntime.ActivityDelegate handling intent launching requests.
    • getActivityDelegate

      @UiThread @Nullable public GeckoRuntime.ActivityDelegate getActivityDelegate()
      Get the GeckoRuntime.ActivityDelegate instance set on this runtime, if any,
      Returns:
      The GeckoRuntime.ActivityDelegate set on this runtime.
    • getSettings

      @AnyThread @NonNull public GeckoRuntimeSettings getSettings()
    • orientationChanged

      @UiThread public void orientationChanged()
      Notify Gecko that the screen orientation has changed.
    • configurationChanged

      @UiThread public void configurationChanged(@NonNull Configuration newConfig)
      Notify Gecko that the device configuration has changed.
      Parameters:
      newConfig - The new Configuration object, Configuration.
    • orientationChanged

      @UiThread public void orientationChanged(int newOrientation)
      Notify Gecko that the screen orientation has changed.
      Parameters:
      newOrientation - The new screen orientation, as retrieved e.g. from the current Configuration.
    • getOrientationController

      @UiThread @NonNull public OrientationController getOrientationController()
      Get the orientation controller for this runtime. The orientation controller can be used to manage changes to and locking of the screen orientation.
      Returns:
      The OrientationController for this instance.
    • getStorageController

      @UiThread @NonNull public StorageController getStorageController()
      Get the storage controller for this runtime. The storage controller can be used to manage persistent storage data accumulated by GeckoSession.
      Returns:
      The StorageController for this instance.
    • getWebPushController

      @UiThread @NonNull public WebPushController getWebPushController()
      Get the Web Push controller for this runtime. The Web Push controller can be used to allow content to use the Web Push API.
      Returns:
      The WebPushController for this instance.
    • appendAppNotesToCrashReport

      @AnyThread public void appendAppNotesToCrashReport(@NonNull String notes)
      Appends notes to crash report.
      Parameters:
      notes - The application notes to append to the crash report.
    • describeContents

      @AnyThread public int describeContents()
      Specified by:
      describeContents in interface Parcelable
    • writeToParcel

      @AnyThread public void writeToParcel(Parcel out, int flags)
      Specified by:
      writeToParcel in interface Parcelable
    • readFromParcel

      @AnyThread public void readFromParcel(@NonNull Parcel source)