• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-1,8141,613

screenshots/device/12-May-2024-

.gitignoreD12-May-2024100 77

README.mdD12-May-20241.3 KiB4321

README_zh.mdD12-May-20241.5 KiB4221

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024168 21

package.jsonD12-May-2024395 1919

README.md

1# Observer
2
3### Overview
4
5This sample demonstrates how to use observer APIs to subscribe to events of network status, signal status, call status, cellular data, and SIM card status changes.
6
7![](./screenshots/device/observer-en.png)
8
9
10### Concepts
11
12`@ohos.telephony.observer`
13
14  A module that allows you to register observers to subscribe to events of mobile network, signal, call, and SIM card status changes.
15
16### Required Permissions
17
18The following permission must be declared in the `module.json5` file:
19
20**ohos.permission.GET_NETWORK_INFO**: Obtains the network status.
21
22**ohos.permission.READ_CALL_LOG**: Obtains the call status.
23
24### How to Use
25
261. Open the application and enable all event subscription switches.
27
282. Enable or disable the mobile network once to trigger a network status change.
29
303. Make a call to trigger a call status change.
31
324. Remove and insert the SIM card to trigger a SIM card status and signal status change.
33
345. Touch the **Details** button. A page is displayed, showing the related status change events.
35
36### Constraints
37
381. This sample can only be run on standard-system devices.
39
402. This sample demonstrates the stage model, which supports only API version 9.
41
423. This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run.
43

README_zh.md

1# observer
2
3### 简介
4
5本示例通过observer接口订阅网络状态、信号状态、通话状态、蜂窝数据、sim状态等事件,并获取状态变化返回的结果。
6
7![](screenshots/device/observer.png)
8
9### 相关概念
10
11observer: 通过注册相关监听事件,来监听手机网络、信号、通话、sim卡等状态,并返回相应的结果。
12
13### 相关权限
14
15获取网络状态权限:ohos.permission.GET_NETWORK_INFO
16
17获取通话状态权限:ohos.permission.READ_CALL_LOG
18
19### 使用说明
20
211.打开应用,开启所有订阅事件开关。
22
232.开关一次网络,触发网络状态变化。
24
253.拨打一次电话,触发通话状态变化。
26
274.插拔一次sim卡,触发sim卡状态变化和信号状态变化。
28
295.点击**查看详情**按钮,跳转详情页,显示监听到的数据结果。
30
31### 约束与限制
32
331.本示例仅支持标准系统上运行。
34
352.本示例需要插入SIM卡,目前该功能仅支持部分机型。
36
373.本示例为Stage模型,从API version 9开始支持。
38
394.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。
40
415.本示例所配置的权限ohos.permission.READ_CALL_LOG为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/))42