• Home
Name Date Size #Lines LOC

..--

AppScope/22-Oct-2025-3633

entry/22-Oct-2025-1,3181,103

hvigor/22-Oct-2025-2422

screenshots/device/22-Oct-2025-

.gitignoreD22-Oct-2025100 77

README.mdD22-Oct-20251,020 2814

README_zh.mdD22-Oct-20252.9 KiB7651

build-profile.json5D22-Oct-20251 KiB4341

hvigorfile.jsD22-Oct-2025168 21

hvigorwD22-Oct-20252.1 KiB6228

hvigorw.batD22-Oct-20252 KiB7356

oh-package.json5D22-Oct-2025819 2725

ohosTest.mdD22-Oct-2025416 86

README.md

1# Cellular Data
2
3### Introduction
4
5This sample shows how to use cellular data APIs to obtain SIM card information.
6
7### Usage Instruction
8
91. Set the default SIM card. The default SIM card is rendered with a blue background.
10
112. Enable or disable the mobile data service. **Turn On** is displayed if the mobile data service is enabled, and **Turn Off** is displayed otherwise.
12
133. Enable or disable the roaming service. **Turn On** is displayed if the roaming service is enabled, and **Turn Off** is displayed otherwise.
14
154. Check **Data Flow Type** for the data flow status of the default SIM card.
16
175. Check **Connect Data** for the data connection status of the default SIM card.
18
19### Constraints
20
211. This sample can only be run on standard-system devices.
22
232. The device must support the SIM card function and have a SIM card installed.
24
253. This sample demonstrates the stage model, which supports only API version 9.
26
274. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run.
28

README_zh.md

1# 蜂窝数据
2
3### 介绍
4
5本示例通过获取SIM卡相关信息,展示打开本应用时网络信息。
6
7本示例使用 [@Builder](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/state-management/arkts-builder.md) 在一个自定义组件内快速生成多个布局内容。
8
9本示例使用 [SystemCapability.Telephony.CellularData](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md) 获取SIM卡信息及网络信息。
10
11### 效果预览
12
13|主页|
14|--------------------------------|
15|![](screenshots/device/index.png)|
16
17使用说明:
18
191.默认移动数据的SIM卡背景色显示为蓝色。
20
212.若已经开启移动数据,则显示开启,否则显示为关闭。
22
233.若已经开启漫游服务,则显示开启,否则显示为关闭。
24
254.显示打开本应用时数据流类型及连接状态。
26
27### 工程目录
28```
29entry/src/main/ets/
30|---Application
31|   |---AbilityStage.ts
32|---common
33|   |---NetWork.ets                    // 网络连接
34|---MainAbility
35|   |---MainAbility.ts
36|---model
37|   |---NetworkMobile.ts               // 蜂窝数据
38|   |---Logger.ts                      // 日志工具
39|---pages
40|   |---Index.ets                      // 首页
41```
42### 具体实现
43
44* 该示例使用蜂窝数据接口,getDefaultCellularDataSlotId方法获取默认移动数据的SIM卡,isCellularDataEnabled方法检查蜂窝数据业务是否启用,isCellularDataRoamingEnabled方法检查蜂窝数据业务是否启用漫游,getCellularDataFlowType方法获取蜂窝数据业务的上下行状态,getCellularDataState方法获取分组交换域(PS域)的连接状态等方法获取SIM卡相关信息,展示打开本应用时网络信息。
45* 源码链接:[NetWork.ets](entry/src/main/ets/common/NetWork.ets),[NetworkMobile.ts](entry/src/main/ets/model/NetworkMobile.ts)
46* 接口参考:[@ohos.telephony.data](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md)
47
48### 依赖
49
50不涉及。
51
52### 相关权限
53
54网络服务:[ohos.permission.GET_NETWORK_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionget_network_info)
55
56### 约束与限制
57
581.本示例仅支持标准系统上运行,支持设备:仅支持部分机型。
59
602.本示例已适配API version 9版本SDK,版本号:3.2.11.9。
61
623.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。
63
644.本示例需设备支持SIM卡功能,且插入SIM卡。
65
66### 下载
67
68如需单独下载本工程,执行如下命令:
69```
70git init
71git config core.sparsecheckout true
72echo code/BasicFeature/Telephony/MobileNetwork/ > .git/info/sparse-checkout
73git remote add origin https://gitee.com/openharmony/applications_app_samples.git
74git pull origin master
75
76```