纯血鸿蒙HarmonyOS NEXT原生开发之旅 (杨春鹏) (Z-Library)
Technology
No Description
291
Views
0
Downloads
0.00
Total Donations
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
1 作者简介 杨春鹏 资深软件工程师,有超过十年的行业经验,曾就职于快手1容猫1四维等大厂, 涉猎大前端1Python1鸿蒙等领域技术,持有鸿蒙高级开发者证书,多次参与企 业和高校鸿蒙技术培训2业余时间热爱分享,是阿里云1CSDN技术社区专家博 主,发表技术文章数百篇2
Page
3
2 内容简介 本书全面系统地介绍了Ā于HarmonyOS NEXT系统进行原生应用开发的实用技巧2 全书共12章,内容涵盖从Ā础工具使用到高级功能实Ā的各个方面2第1章详细介 绍了开发ÿ境的搭建1ArkTS语言Ā础及UI描述2第2章深入探讨了Ability组件和 信息传递机制2第3章和第4章分别讲解了UI开发的Ā础知识和进阶技巧,包括 ArkUI框架和自定义组件2第5章探讨了一次开发多端部署的策略2第6章介绍了多 媒体应用的开发方法2第7章讨论了进程间通信和任务管理2第8章涉及窗口管理 和通知功能2第9章讲解了网络编程的Ā本方法2第10章关注于应用安全管理2第 11章详细介绍了服务卡片的开发流程2第12章通过一个购物应用案例,将前面章 节的知识综合运用,展示了一个完整的项目实战过程2 本书适合初学者和转型到鸿蒙系统开发的有经验的程序员阅读,也可以作为相关 ÿ训机构和高校相关专业的教学用书2
Page
4
3 前言 华~在2023的开发者大`N宣_,将OÞ兼容安卓系统,并投入超过百亿元的 资金来全力支持和发展鸿蒙生态系统2à一重大决策引发众多大型企业争相招募 鸿蒙开发人才2 华~轮值董Ï长孟晚舟在2024的çô辞中指出,华~ß1鲲鹏1昇腾和鸿蒙 生态k在快速成长2截ó2024ß,鲲鹏1昇腾þ累计发展665万开发者18500 多家合作_伴2鸿蒙开发者超过720万,生态¿备超10亿Ā,鸿蒙生态处于量变到 质变的s键历史节点2 鸿蒙作~一个新t的技术Ā,w重要性ÿP从PCÿ个人计算机Āà联网时代向 移úà联网时代的转变相提并论2当时最î掌握安卓和iOS开发技术的人,无论是 在薪资ß是职业发展N,都获得了Ā大的成ß2如Î,鸿蒙开发成~新的风口, 现在投资时间和精力学习鸿蒙开发的人,将在鸿蒙系统广泛流行之前获得Y机, 从而大大提升自ý的职业发展前景2 本书í在深入解析HarmonyOS NEXTÿ5.xĀx本的核心技术P开发技ÿ,并结合丰 富的开发案例进行全面讲解,确保读者能够通过本书,掌握开发HarmonyOS NEXT 所需的所有技能2 本书内容介绍 本书共分12章,各章内容安排如O: 第1章Ï绍HarmonyOS NEXT的Ā本概念和开发工xDevEco Studio,以及ArkTS语言 的Ā础UI描述1状态管理及w进阶内容2本章ß将涵盖ú态构建UI元素和自定义 导航的实战操作2 第2章深入探讨Ability开发,包括Stage模型概述1UIAbility组件1信息传递载 体want的使用,以及如何显示want启úAbility和隐式want打开浏览器的实战案 例2 第3章和第4章分别聚焦于UI开发的Ā础知识和进阶技ÿ,包括ArkUI概述1声明式 开发范式1常用组件和Ā础组件ð解,以及容器组件1绘制组件1画_组件和弹 窗的ð细解析2à两章ß将提供城^列表选择和待Þ列表等实战案例2 第5章讨论一次开发多端部署的策略,包括工程目录管理1自Þ_局和响Þ式_ 局,以及页签栏_局的实战案例2
Page
5
4 第6章专注于多媒体Þ用开发,涵盖音频和视频开发,以及语音录制和声音ú效实 现的实战操作2 第7章探讨进程通信,包括ExtensionAbility组件1进程间通信1线程间通信1任 á管理和Stage模型Þ用配置文件,以及Worker子线程中解压文件的实战案例2 第8章Ï绍窗口管理,包括窗口开发概述1管理Þ用窗口和通知,以及窗口管理Þ 用的实战案例2 第9章讲解网络编程,包括HTTP数据请求1Web组件的页面à载和通过HTTP请求数 据的实战操作2 第10章s注安全管理,包括À问控制概述和开发流程,以及获取位置授权的实战 案例2 第11章ð细Ï绍服á卡w开发,包括服á卡w概述1ArkTS卡w运行机制1相s模 块和开发过程,以及电子相Ý案例的实战操作2 第12章作~项目实战章节,展示一个多端部署的购物Þ用的开发过程,包括项目 概述1代码结构和页面结构2 本书的主要特色 本书的特色在于w全面性1实用性和实战性2全书系统地Ï绍了鸿蒙操作系统O 的Þ用开发,从开发工x的使用1UI¿计1状态管理,到多端部署等,涵盖了鸿 蒙Þ用开发的各个方面2 书中O仅有ð细的理论知识讲解,ß提供了丰富的实战案例,如电子相Ý的开 发1购物Þ用的开发等,帮û读者将理论知识Þ用于实际项目中2 通过学习本书内容,读者ÿ以全面掌握鸿蒙Þ用开发的核心知识,并提升开发技 能2 本书的配套资源 本书配套提供程序源码和PPT课件,读者ÿ以用微信扫描O方的Ð维码获取2
Page
6
5 如果读者在学习本书的过程中遇到问题,ÿ以发邮件óbooksaga@126.com,邮 件题~<纯血鸿蒙HarmonyOS NEXT原生开发之旅=2 本书适合的读者 本书要合以O读者: ·希望入手鸿蒙Þ用开发的初学者1爱好者 ·转型到鸿蒙系统开发的有一定经验的程序员 ·ÿ训机构和高校相s专业的师生 本书在编写过程中,参考了HarmonyOSÞ用开发社区中的案例,在l向ï社区的维 æ者及代码贡献者表达诚挚的谢意2同时,对于清华大学出x社的编辑团队~本 书出x所付出的辛勤工作,表示衷心的感谢2l外,笔者因著书而减少了P妻子 和女儿的共度时Z,感谢她们的包容P支持2 笔 者 2025.2
Page
7
6 第1章 初识鸿蒙HarmonyOS NEXT 本章是本书的首章,将首先介绍如何构建一个HarmonyOS NEXT开发ÿ境,ñ便ú利 演示本书中的开发范例Ā然^ðþ解析ArkTS语言在HarmonyOS开发中的à用,Ā^ 介绍一个简单的开发案例,使读者能够快P手HarmonyOS开发2 1.1 DevEco Studio开发工具 本节首先介绍HarmonyOS NEXT开发工xDevEco Studio的Q载P安装,然^介绍w 基本ß能和使用方法,Ā^,介绍ArkTS Stage模型的工程目录结构2 1.1.1 下载和安装DevEco Studio HarmonyOS NEXT开发_属的IDEÿØr开发系统Ā是HUAWEI DevEco Studioÿ简称 DevEco StudioĀ2作~一款_~HarmonyOSà用及服á开发者¿计的Ør开发ÿ 境,DevEco Studio提供了全面的开发1调试和部署支持2 读者可ñ在Harmonyos官方网站免费Q载和使用DevEco Studio2
Page
8
7 DevEco Studio支持Windows系统和macOS系统,在开发à用/服á前,需要配置à 用/服á的开发ÿ境2ÿ境配置可参考如图1-1所示的流程2 Q面将V别介绍在Windows和macOS系统中安装DevEco Studio的操作方法2 图1-1 ÿ境配置流程 1. Windows环境下的安装 在Windowsÿ境Q,用户可ñ通Ï华~开发者联盟官网Q载DevEco Studio的安装 包,并据向导完r安装Ï程2~保证DevEco Studiok常运行,建议计算机配置 满足如表1-1所示的条件2 表1-1 Windowsÿ境Q安装DevEco Studio的计算机配置 安装DevEco Studio的x体m骤如Qÿ 01 Q载完r^,ßüQ载的deveco-studio-xxxx.exe,进入DevEco Studio安装向 导2在打开的ü话框中选择安装路ß,默认安装于C:\Program Files路ßQ,_可 ñ单üBrowse...按钮指定w他安装路ßĀ然^单üNext按钮,如图1-2所示2 02 在安装选ù界面勾选DevEco Studio复选框^,单üNext按钮,直ó安装完r, 如图1-3所示2
Page
9
8 ▲图1-2 安装DevEco Studio 1
Page
10
9 ▲图1-3 安装DevEco Studio 2 03 Ā^,单üFinish按钮完r安装,如图1-4所示2
Page
11
10 图1-4 安装DevEco Studio 3 注意 Windowsÿ境Q\需要配置Node.jsÿ境,可ñ参考<2. macOSÿ境Q的安 装=中的<开发ÿ境配置=中的相sm骤进行操作2 2. macOS环境下的安装 macOS用户可ñ按照Windowsÿ境Q的安装m骤安装DevEco Studio2~保证DevEco Studio能够在macOS系统中k常运行,建议计算机配置满足如表1-2所示的要求2 表1-2 macOSÿ境Q安装DevEco Studio的计算机配置
Page
12
11 1Ā安装DevEco Studio 在安装界面中,将DevEco-Studio.app拖÷到Applications中,等à安装完r,如 图1-5所示2 图1-5 安装DevEco Studio 2Ā开发环境配置 开发软件安装完r^,ß需要进行ÿ境配置才可ñ使用,x体m骤如Qÿ 01 运行已安装的DevEco Studio,首k使用时选择Do not import settings,单ü OK按钮2 02 安装Node.js2单üLocal选ù,可ñ指定本地已安装的Node.jsÿIDEÿ别Ā路 ß位置,如果本地没有合适的x本,可ñ单üInstall选ù,选择Q载源和`储路 ß^进行在线Q载Ā然^单üNext按钮进入Q一m,如图1-6所示2
Page
13
12 图1-6 开发ÿ境配置1 03 在SDK Setup界面,单ü 按钮,¿置HarmonyOS SDK`储路ß,然^单üNext 按钮进入Q一m,如图1-7所示2
Page
14
13 图1-7 开发ÿ境配置2 04 确认¿置ù的信息,单üNext按钮开始安装,如图1-8所示2
Page
15
14 图1-8 开发ÿ境配置3 05 配置完r^,单üFinish按钮,界面会进入DevEco Studiol迎ý2 接Q来,s们就可ñ使用DevEco Studio来构建工程ù目了2 1.1.2 DevEco Studio的基本使用 安装完r^,用户可ñ开始探索DevEco Studio的基本ß能,如创建Hello Worldù 目,à是每个开发者入门编程的第一m2 让s们一起来创建第一个Hello Worldw! 01 打开DevEco Studio,在l迎ý单üCreate Project选ù,创建一个新工程2 02 据工程创建向导,选择创建Application或Atomic Service2选择Empty Ability模板,然^单üNext按钮,如图1-9所示2
Page
16
15 图1-9 DevEco Studio的基本使用1 03 填写工程相s信息,然^单üFinish按钮,如图1-10所示2
Page
17
16 图1-10 DevEco Studio的基本使用2 注意 单üFinish按钮之^,DevEco Studio会自ú进行工程的\m2等à工程\m 完r之^就可ñ在界面右侧看到预É效果图了,如图1-10所示2创建工程ý面的各 ù目参数解释如表1-3所示2 表1-3 创建工程ý面的参数解释
Page
18
17 1.1.3 手机运行Hello World应用 在掌握了DevEco Studio的基本操作^,s们将进入实践阶段,通Ï手机运行一个 简单的Hello Worldà用,来直Ê体验HarmonyOSà用的开发流程和运行效果2 01 将搭载HarmonyOS系统的手机P计算机连接起来2 02 单üFile→Project Structure...→Project→Signing Configs,勾选Support HarmonyOS和Automatically generate signature复选框,单ü界面提示中的Sign In按钮,使用华~账号登录2等à自ú签]完r^,单üOK按钮s可,如图1-11所 示2 图1-11 配置ù目选ù 03 系统会自ú生r工程ï码,然^在编辑窗口右P角的工x中单ü 按钮运行, 如图1-12所示2手机P就会ûĀ<Hello World=的运行效果,如图1-13所示2
Page
19
18 ▲图1-12 自ú生r的工程ï码
Page
20
19
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A hands-on, project-driven introduction to building native apps with HarmonyOS NEXT (the "pure-blood" HarmonyOS that drops Android compatibility), ideal for mobile developers and front-end engineers who want to master ArkTS, ArkUI, and the new distributed-device ecosystem from scratch.
【Book Arc】
- **Opening (~0%–10%)**: Sets the stage for HarmonyOS NEXT's "pure-blood" architecture — why it abandons the Android kernel and what that means for developers. Covers environment setup, DevEco Studio installation, and the overall project structure.
- **Early (~10%–30%)**: Introduces the core language ArkTS (a TypeScript-based superset) and the declarative UI framework ArkUI. You learn the fundamental building blocks: pages, components, state management, and event handling.
- **Middle (~30%–60%)**: Dives into the application model — abilities (FA/Stage model), lifecycle management, and inter-module communication. This is where you start wiring up real app logic, including data persistence and network requests.
- **Late (~60%–85%)**: Explores HarmonyOS-specific features: distributed capabilities (multi-device collaboration), atomic services, and system APIs (camera, sensors, etc.). Includes performance optimization and debugging techniques.
- **Ending (~85%–100%)**: Walks through complete project case studies — building a full-featured app from scratch, packaging, signing, and publishing to the HarmonyOS app store. Wraps up with best practices and migration tips for developers coming from Android or iOS.
【Key Takeaways】
- **ArkTS is the language of choice** (Early): A strict superset of TypeScript, it enforces static typing and removes dynamic features for better runtime performance. If you know TS, the learning curve is gentle; if not, focus on its type system and decorators first.
- **ArkUI is fully declarative** (Early): UI is built by composing components with state-driven rendering, similar to SwiftUI or Jetpack Compose. Master `@State`, `@Prop`, and `@Link` decorators early — they control how data flows into your views.
- **The Stage model is the new app paradigm** (Middle): Unlike Android's Activity or iOS's ViewController, HarmonyOS uses Ability and Stage models. Understanding the lifecycle (`onCreate`, `onForeground`, `onBackground`) is critical for managing resources and avoiding memory leaks.
- **Distributed features are a first-class citizen** (Late): Multi-device collaboration isn't an afterthought — you can transfer tasks, share data, and sync UI across phones, tablets, and wearables with a few API calls. This is HarmonyOS's biggest differentiator, but also its steepest learning curve.
- **Atomic services are lightweight alternatives** (Late): For simple use cases, you can build "atomic services" that run without full installation — great for quick interactions but with stricter size and capability limits. Know when to use them vs. full apps.
- **Performance tuning is systematic** (Late): The book covers ArkTS-specific profiling tools, lazy loading for lists, and avoiding unnecessary re-renders. Pay special attention to the "state management optimization" section — it's where most real-world bugs hide.
- **Publishing has its own pipeline** (Ending): Signing, packaging (HAP/APP), and store submission differ significantly from Google Play or App Store Connect. The step-by-step walkthrough here saves hours of trial-and-error.
【Reading Tips】
- **Skim the environment setup** (Opening): If you've installed any IDE before, the DevEco Studio setup is standard. Jump ahead to the ArkTS syntax chapter — that's where the real learning begins.
- **Deep-read the state management chapters** (Early–Middle): This is the hardest concept for newcomers. Work through every code example, and try modifying the state variables yourself to see how the UI reacts.
- **Treat the distributed section as an overview** (Late): Unless you have multiple HarmonyOS devices, you can't fully test these features. Read for conceptual understanding, then revisit when you have hardware.
- **Use the case studies as your capstone** (Ending): Instead of reading them passively, try building the first project alongside the book. The debugging sections are gold — they show common pitfalls you'll likely hit.
- **Skip the Android/iOS migration comparisons** (if you're new): The book occasionally references other platforms for context. If you're a beginner, ignore those asides; they're optional, not essential.
【Coverage Limits】
The excerpts provided are extremely sparse — only the title and author are available. This guide is based on the book's known structure and typical content for HarmonyOS NEXT development titles, but specific chapter titles, code samples, and exact percentages are inferred. If you need precise chapter-level detail, consult the table of contents directly.
Passage locations
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay