# hms-search-demo
**Repository Path**: hms-core/hms-search-demo
## Basic Information
- **Project Name**: hms-search-demo
- **Description**: 华为搜索服务示例代码。介绍了如何使用Search Kit的各项能力,如:网页搜索、图片搜索、视频搜索、新闻搜索、文本补齐和拼写纠错等。
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 56
- **Forks**: 0
- **Created**: 2021-02-19
- **Last Updated**: 2025-09-02
## Categories & Tags
**Categories**: harmony
**Tags**: None
## README
# HMS Search Kit Demo
English | [中文](https://github.com/HMS-Core/hms-search-demo/blob/main/README_ZH.md)
## Table of Contents
* [Introduction](#introduction)
* [Installation](#installation)
* [Supported Environments](#supported-environments)
* [Configuration ](#configuration)
* [Sample Code](#sample-code)
* [License](#license)
## Introduction
HMS Search Kit sample code encapsulates APIs of the HUAWEI Search Kit. It provides a sample programs for your reference or usage.
## Installation
Before using HMS Search Kit sample code, check whether the BD_SearchKitCodeLab environment has been installed.
Decompress the HMS Search Kit sample code package.
Refresh the project and ensure that is successfully.
## Supported Environments
searchkit 5.0.4.305 or a later version is recommended.
The Android SDK is available only on a mobile device running Android API-Level 24 (Android 7.0 Marshmallow) or higher.
Android studio.
## Configuration
1. Register and sign in to HUAWEI Developers.
2. Create a project and then create an app in the project, enter the project package name.
3. Go to Project Settings > Manage APIs, find the Search Kit API, and enable it.
4. Go to Project Settings > General information, click Set next to Data storage location under Project information, and select a data storage location in the displayed dialog box.
5. Download the agconnect-services.json file and place it to the app's root directory of the project.
6. Add the Maven repository address maven {url 'https://developer.huawei.com/repo/'} and plug-in class path 'com.huawei.agconnect:agcp:1.3.1.300' to the project-level build.gradle file.
7. Add apply plugin: 'com.huawei.agconnect' to the last line of the app-level build.gradle file.
8. Configure the dependency com.huawei.hms:searchkit:5.0.4.305 in the app-level buildle.gradle file.
9. Synchronize the project.
## Sample Code
1. Web search.
Code location: [searchindex/SearchActivity.java](https://github.com/HMS-Core/hms-search-demo/blob/main/SearchKit_android_SampleCode/app/src/main/java/com/huawei/searchindex/activity/SearchActivity.java)
2. Image search.
Code location: [searchindex/SearchActivity.java](https://github.com/HMS-Core/hms-search-demo/blob/main/SearchKit_android_SampleCode/app/src/main/java/com/huawei/searchindex/activity/SearchActivity.java)
3. Video search.
Code location: [searchindex/SearchActivity.java](https://github.com/HMS-Core/hms-search-demo/blob/main/SearchKit_android_SampleCode/app/src/main/java/com/huawei/searchindex/activity/SearchActivity.java)
4. News search.
Code location: [searchindex/SearchActivity.java](https://github.com/HMS-Core/hms-search-demo/blob/main/SearchKit_android_SampleCode/app/src/main/java/com/huawei/searchindex/activity/SearchActivity.java)
5. Custom search.
Code location: [searchindex/SearchActivity.java](https://github.com/HMS-Core/hms-search-demo/blob/main/SearchKit_android_SampleCode/app/src/main/java/com/huawei/searchindex/activity/SearchActivity.java)
6. Suggest.
Code location: [searchindex/SearchActivity.java](https://github.com/HMS-Core/hms-search-demo/blob/main/SearchKit_android_SampleCode/app/src/main/java/com/huawei/searchindex/activity/SearchActivity.java)
7. Spell check.
Code location: [searchindex/SearchActivity.java](https://github.com/HMS-Core/hms-search-demo/blob/main/SearchKit_android_SampleCode/app/src/main/java/com/huawei/searchindex/activity/SearchActivity.java)
## Result
**web search**
**image search**
**video search**
**news search**
## License
HMS Search Kit sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).