Run sample Code
Register as a DJI Developer
Register for a DJI Developer account here.
During the registration process, email information and a credit card or phone number will need to be supplied to verify the registration. Any credit card information given will only be used for verification and will not be charged.
This guide assumes you are using Android Studio Bumblebee 2021.1.1 and above.
Generate an App Key
Every application needs a unique App Key to initialize the SDK.
To create an App Key for an application:
Go to the DJI developer Developer Center
- Select the "Apps" tab on the left.
- Select the "Create App" button on the right.
- Enter the APP Name, Software Platform, Package Name, Category, and Description.
- An application activation email will be sent to complete App Key generation.
- The App Key will appear in the developer center, and can be copied and pasted into the application.
Android Sample App
The SDK doesn't need to be downloaded to run the Android sample application as it's already included in the project.
Android Sample Code Setting
Download or clone the MSDK Android sample project from Github: https://github.com/dji-sdk/Mobile-SDK-Android-V5。
If you want to use their own project, generated "App Key" string should be copied to
android:value=""in "AndroidManifest.xml" file.
<!-- ADD API_KEY HERE and make sure you are connected to the Internet before the app is launched --> <meta-data android:name="com.dji.sdk.API_KEY" android:value="" />
- If you use the MSDK sample project directly, our sample project has packaged the setting at setp 2. Open the sample project at Android Studio, you can replace the
AIRCRAFT_API_KEY = Please add your app key here.in "gradle.properties" by generated "App Key" string.
Run the Sample App
Compile and install the sample code into the M30 Series remote controller (ie DJI RC Plus), and then connect the DJI RC Plus to the M30 Series aircraft to run the sample application.
Before the usage, MSDK Sample will apply for some permissions. The following are the range of possible permission application.
<!-- SDK permission requirement --> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
The following permissions must be opened, the rest can be open according to users' requirements.
- INTERNET: Allows applications to open network sockets.
- ACCESS_COARSE_LOCATION: Allows an app to access approximate location.
- ACCESS_NETWORK_STATE: Allows applications to access information about networks.
- ACCESS_FINE_LOCATION: Allows an app to access precise location.
- WRITE_EXTERNAL_STORAGE: Allows an application to write to external storage.
- READ_EXTERNAL_STORAGE: Allows an application to read from external storage.
- READ_PHONE_STATE: Allows read only access to phone state, including the current cellular network information, the status of any ongoing calls, and a list of any PhoneAccounts registered on the device.
Press to check precise meaning of permissions.
If the words "Registration Status: Registered" appear in the upper left corner of the main interface of the Sample, the sample code is running successfully, and "Product Name: M30_SERIES" appears, indicating that the MSDK is successfully connected to the aircraft. The following figure shows the flow chart of the SDK Manager API call.
When starting a third-party App based on MSDK on the remote controller(DJI RC Plus) that matching M30 series aircraft, official app DJI Pilot should be forcibly exited from the application and notification interface under the DJI RC Plus remote controller system settings interface to ensure a normal start of the third-party app.