English | 中文
This sample code encapsulates APIs of the HUAWEI Drive Kit SDK. It provides many sample programs for your reference or usage. You will learn how to use Drive Kit SDK.
The following describes packages of Java sample code.
app: Sample code packages.
For more development details, please refer to the following link:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/introduction-0000001050039630
Before using HUAWEI Drive Kit SDK sample code, check whether the JAVA environment has been installed.
Clone the sample code to local.
Take the Android Studio 3.2 version as an example. The steps to run the Drive service sample code are as follows:
- You should create an app in AppGallery Connect, and obtain the file of agconnect-services.json and add to the project.
- You should also generate a signing certificate fingerprint and add the certificate file to the project, and add configuration to build.gradle.
See the Configuring App Information in AppGallery Connect guide to configure app in AppGallery Connect. - In Android Studio, select "File"->"Open". In the pop-up dialog box, enter the path where the sample code is stored locally, for example: "D:\HuaweiDriveSDK\samples\HuaweiDriveSample-4.0.3.300";
- Select the HuaweiDriveSample project to be opened, and then click "OK". In the pop-up dialog box, select "New Window" to open the project in a new window.
- In Android Studio, click "Run", then select your device as the target and click "OK" to launch the sample application on your device.
To use functions provided by packages in examples, you do not need to set any related parameters in build.gradle and agconnect-services.json in the app package
The following describes parameters in build.gradle and agconnect-services.json
applicationId: ID of the application registered on the HUAWEI Developer.
app_id: App ID, which is obtained from app information.
Devices to be tested: Huawei phones running EMUI 10.0 or later or non-Huawei phones running Android 10.0 or later. If multiple HMS Core services are used at the same time, the maximum value of each Kit must be used.
Java 1.8 or a later version is recommended.
Android Studio 3.2 version or a later version is recommended.
Your application should meet the following conditions: minSdkVersion 29 targetSdkVersion 33 compileSdkVersion 30 Gradle 3.5.4 and later.
Currently, the core capabilities of Drive Kit include uploading, downloading, deleting, trashing, and searching for files in Drive as well as querying and monitoring file changes.
- Obtain parameters in the Main function of each Java file in advance. For example, obtain the AT through the HMS SDK.
- Call the required APIs. Some APIs depend on each other, for example:
- Before calling
FILES.CREAEFILE
, you need to callFILES.CREATE
. - Before calling
FILES.GET,FILES.SUBSCRIBE,FILES.COPY,FILES.UPDATE,FILES.UPDATECONTENT,CHANGES.SUBSCRIBE,COMMENTS.CREATE,COMMENTS.LIST
, you need to callFILES.CREATE and FILES.CREATEFILE
. - Before calling
CHANGES.LIST
, you need to callCHANGES.GETSTARTCURSOR
. - Before calling
CHANNELS.STOP
, you need to callCHANGES.SUBSCRIBE
. - Before calling
COMMENTS.GET
, you need to callCOMMENTS.CREATE
. - Before calling
Replies.CREATE
, you need to callCOMMENTS.CREATE
.
If you want to evaluate more about HMS Core, r/HMSCore on Reddit is for you to keep up with latest news about HMS Core, and to exchange insights with other developers.
If you have questions about how to use HMS samples, try the following options:
- Stack Overflow is the best place for any programming questions. Be sure to tag your question with
huawei-mobile-services
. - Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
If you run into a bug in our samples, please submit an issue to the Repository. Even better you can submit a Pull Request with a fix.
DriveKit SDK sample is licensed under the Apache License, version 2.0.