Actions

Overview

Android SDK provides Action class, which exposes a number of methods to perform actions such as on and off of the motors, takeoff and landing of the drone, and other related flight control function. Simultaneously, developers can also get and set the takeoff height.

Action class of SDK provides functions to perform actions on the drone such as arm/disarm, take off/land, and RTL (return-to-land).

The following code snippets demonstrates, how to use Action class in the SDK for various functions. 

  1. Arm the drone
    armAsync(Action.ResultListener listener)
  2. Disarm the drone
    disarmAsync(Action.ResultListener listener)
  3. Return to launch - land at the takeoff location
    returnToLaunchAsync(Action.ResultListener listener)
  4. Initiates takeoff and hovers at the takeoff altitude.
    takeoffAsync(Action.ResultListener listener)

 

You need to register to the ResultListener of Action class, to get the result of performing any action. The following code snippet demonstrates how to register to the listener and receive callbacks.


public static void registerActionListener() {
   Action.ResultListener actionResultListener = new Action.ResultListener() {
      @Override
      public void onResultCallback(Action.Result result) {
      // Handle result
      Log.d(TAG, result.resultStr);
      }
   };
}

 

Please refer the API documentation for more information about this feature.