ManagedGroundSdk

class ManagedGroundSdk : GroundSdk

An GroundSdk session automatically managed according to an android Activity lifecycle.

This class allows the application to retrieve a GroundSdk session whose lifecycle is is automatically managed in correlation with a given Activity's own lifecycle.This is the recommended way to use GroundSdk API in an android Activity.

The application should obtain such a session in the onCreate method. None of the session's lifecycle management methods, as described in GroundSdk documentation, need to be called.

  • The session is automatically retained and restored upon configuration changes.
  • The session is resumed when the activity calls through super.onStart() method (by default, but the application may chose to have it resumed in when the activity calls through super.onResume() method instead).
  • The session is suspended when the activity calls through super.onStop() method (by default, but the application may chose to have it suspended in when the activity calls through super.onPause() method instead).
  • The session is automatically closed when the activity calls through onDestroy. The application MUST NOT use the session past this point.

For example:

 public class MyManagedGroundSdkActivity extends Activity {
     private ManagedGroundSdk mGroundSdk;

    @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         mGroundSdk = ManagedGroundSdk.obtainSession(this);
     }

    @Override
     public void onDestroy() {
         super.onDestroy();
         // mGroundSdk MUST NOT be used anymore past this point
     }
 }

Types

ObserverBehavior
Link copied to clipboard
enum ObserverBehavior
Allows to specify when a managed GroundSdk session will resume/suspend its registered observers.

Functions

close
Link copied to clipboard
open fun close()
Closes this session.
connectDrone
Link copied to clipboard
fun connectDrone(@NonNull uid: String): Boolean
Connects a drone identified by its uid.
fun connectDrone(@NonNull uid: String, @NonNull connector: DeviceConnector): Boolean
Connects a drone identified by its uid using a specific connector.
fun connectDrone(@NonNull uid: String, @NonNull connector: DeviceConnector, @NonNull password: String): Boolean
Connects a secured drone identified by its uid.
connectRemoteControl
Link copied to clipboard
fun connectRemoteControl(@NonNull uid: String): Boolean
fun connectRemoteControl(@NonNull uid: String, @NonNull connector: DeviceConnector, @NonNull password: String): Boolean
Connects a remote control identified by its uid.
fun connectRemoteControl(@NonNull uid: String, @NonNull connector: DeviceConnector): Boolean
Connects a remote control identified by its uid using a specific connector.
disconnectDrone
Link copied to clipboard
fun disconnectDrone(@NonNull uid: String): Boolean
Disconnects a drone identified by its uid.
disconnectRemoteControl
Link copied to clipboard
fun disconnectRemoteControl(@NonNull uid: String): Boolean
Disconnects a remote control identified by its uid.
forgetDrone
Link copied to clipboard
fun forgetDrone(@NonNull uid: String): Boolean
Forgets a drone identified by its uid.
forgetRemoteControl
Link copied to clipboard
fun forgetRemoteControl(@NonNull uid: String): Boolean
Forgets a remote control identified by its uid.
getDrone
Link copied to clipboard
fun getDrone(@NonNull uid: String): Drone
fun getDrone(@NonNull uid: String, @NonNull listener: GroundSdk.OnDeviceRemovedListener): Drone
Gets a drone by uid.
getDroneList
Link copied to clipboard
fun getDroneList(@NonNull filter: Predicate<DroneListEntry>, @NonNull observer: Ref.Observer<List<DroneListEntry>>): Ref<List<DroneListEntry>>
Gets a list of known drones and registers an observer notified each time this list changes.
getFacility
Link copied to clipboard
fun <F : Facility?> getFacility(@NonNull facilityClass: Class<F>): F
Retrieves a facility.
fun <F : Facility?> getFacility(@NonNull facilityClass: Class<F>, @NonNull observer: Ref.Observer<F>): Ref<F>
Retrieves a facility and registers an observer notified each time it changes.
getRemoteControl
Link copied to clipboard
fun getRemoteControl(@NonNull uid: String): RemoteControl
Gets a remote control by uid.
getRemoteControlList
Link copied to clipboard
Gets a list of known remote controls and registers an observer notified each time this list changes.
manageRcAccessory
Link copied to clipboard
open fun manageRcAccessory(@NonNull context: Context, @NonNull rcAccessory: UsbAccessory)
Commands GroundSDK to manage the given remote controller USB accessory.
newSession
Link copied to clipboard
open fun newSession(@NonNull context: Context, @Nullable savedInstanceState: Bundle): GroundSdk
Obtains a new GroundSdk session instance.
obtainSession
Link copied to clipboard
open fun obtainSession(@NonNull activity: Activity): ManagedGroundSdk
open fun obtainSession(@NonNull activity: Activity, @NonNull observerBehavior: ManagedGroundSdk.ObserverBehavior): ManagedGroundSdk
Obtains a GroundSdk session automatically managed according to the provided activity's lifecycle.
replay
Link copied to clipboard
fun replay(@NonNull source: FileReplay.Source, @NonNull observer: Ref.Observer<FileReplay>): Ref<FileReplay>
Creates a new replay stream for some local media file.
resume
Link copied to clipboard
open fun resume()
Resumes this session.
retain
Link copied to clipboard
open fun retain(@NonNull outState: Bundle)
Retains this session.
suspend
Link copied to clipboard
open fun suspend()
Suspends this session.