Last active
January 18, 2022 13:41
-
-
Save chenglu/ccf943b858d2a5f733233a95d7bad6d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
00:00:08,717 --> 00:00:10,010 | |
大家好 我是 Jay | |
Hi, I’m Jay. | |
2 | |
00:00:10,511 --> 00:00:11,428 | |
我是 Stav | |
And I’m Stav. | |
3 | |
00:00:11,512 --> 00:00:13,931 | |
我们都是 Android Auto 团队的工程师 | |
We're both engineers on the Android Auto team, | |
4 | |
00:00:14,014 --> 00:00:17,017 | |
今天我们将讨论如何使用 Car App Library | |
and today we'll be talking about bringing your apps to cars | |
5 | |
00:00:17,100 --> 00:00:19,102 | |
将您的应用部署到汽车上 | |
using the Car App Library. | |
6 | |
00:00:19,186 --> 00:00:22,773 | |
说到汽车应用 实际上需分两种情况 | |
When we talk about apps for cars, we’re really talking about two things. | |
7 | |
00:00:22,856 --> 00:00:25,901 | |
首先 用户可以通过 Android Auto 应用 | |
The first is Android Auto, which enables users | |
8 | |
00:00:25,984 --> 00:00:28,987 | |
将自己的 Android 手机连接到兼容的车辆 | |
to connect their Android phones to compatible vehicles | |
9 | |
00:00:29,071 --> 00:00:32,533 | |
然后直接在车载显示屏上使用喜欢的应用和服务 | |
and use their favorite apps and services right on the car’s display. | |
10 | |
00:00:32,783 --> 00:00:37,579 | |
其次是 Android Automotive OS 这是一个直接在汽车上运行的 Android 系统 | |
The second is Android Automotive OS, where Android runs directly on the car, | |
11 | |
00:00:37,663 --> 00:00:40,165 | |
为车载信息娱乐系统提供支持 | |
powering the in-car infotainment system | |
12 | |
00:00:40,290 --> 00:00:43,335 | |
同时让驾驶员无需互联设备 | |
as well as giving drivers access to their favorite apps | |
13 | |
00:00:43,460 --> 00:00:44,962 | |
即可访问自己喜欢的应用 | |
without a connected device. | |
14 | |
00:00:45,504 --> 00:00:48,840 | |
最后 如果上述两种方式都不可行的话 | |
And lastly, for Android users without a compatible car, | |
15 | |
00:00:48,924 --> 00:00:53,262 | |
我们还提供了 Google 助理驾驶模式 但今天暂不讨论这个话题 | |
we offer Google Assistant driving mode, but we won’t be focusing on that today. | |
16 | |
00:00:54,221 --> 00:00:56,807 | |
Android Auto 的发展势头依然强劲 | |
Android Auto continues to see strong momentum. | |
17 | |
00:00:56,890 --> 00:01:00,477 | |
目前 全球 1 亿多辆汽车都搭载该系统 | |
It's now available in more than 100 million cars globally, | |
18 | |
00:01:00,561 --> 00:01:03,855 | |
得到几乎所有主要汽车制造商的支持 | |
with support from nearly every major car manufacturer. | |
19 | |
00:01:04,439 --> 00:01:07,484 | |
Android Automotive OS 也受到极大的关注 | |
Android Automotive OS is seeing great traction as well. | |
20 | |
00:01:07,568 --> 00:01:11,154 | |
到 2021 年底 沃尔沃通用汽车和雷诺的 10 多款车型 | |
By the end of 2021, Automotive OS with Google built-in | |
21 | |
00:01:11,238 --> 00:01:16,451 | |
都会搭载内置了 Google 服务的 Automotive OS | |
will be available in more than 10 car models from Volvo, General Motors, and Renault, | |
22 | |
00:01:16,660 --> 00:01:19,955 | |
我们也与福特和本田达成合作 | |
and we recently announced partnerships with Ford and Honda | |
23 | |
00:01:20,038 --> 00:01:23,125 | |
今后会有数百万辆汽车搭载该系统 | |
to bring this experience to millions of future vehicles. | |
24 | |
00:01:23,250 --> 00:01:24,918 | |
这些不断发展的平台 | |
These growing platforms represent | |
25 | |
00:01:25,002 --> 00:01:27,838 | |
为开发者提供了绝佳机会 | |
an amazing opportunity for you as a developer, | |
26 | |
00:01:28,005 --> 00:01:30,465 | |
这正是 Car App Library 的用武之地 | |
and that’s where the Car App Library comes in. | |
27 | |
00:01:31,133 --> 00:01:34,344 | |
通过使用 Car App Library 您只需编写一次代码 | |
The Car App Library allows you to write your code once | |
28 | |
00:01:34,428 --> 00:01:37,723 | |
便可构建同时兼容 Android Auto 和 | |
and make your app available across both Android Auto | |
29 | |
00:01:37,848 --> 00:01:40,058 | |
Android Automotive OS 的应用 | |
and Android Automotive OS. | |
30 | |
00:01:40,434 --> 00:01:43,604 | |
设计界面时我们考虑到了驾驶员的安全 | |
The interface is designed with driver safety in mind, | |
31 | |
00:01:43,687 --> 00:01:46,815 | |
因此 您无需精通驾驶员安全相关知识 | |
which in turn helps you build apps that are safer | |
32 | |
00:01:47,065 --> 00:01:49,985 | |
也可以设计出有利于驾驶员安全的应用 | |
without needing to become an expert on driver safety. | |
33 | |
00:01:50,902 --> 00:01:54,031 | |
语音是汽车输入的重要形式 | |
Voice is an important form of input in cars, | |
34 | |
00:01:54,114 --> 00:01:56,158 | |
使用 Car App Library 构建的应用 | |
so apps built with the Car App Library | |
35 | |
00:01:56,241 --> 00:01:59,703 | |
可以与语音助理无缝集成 | |
enable you to have seamless integrations with voice assistants. | |
36 | |
00:02:00,120 --> 00:02:03,206 | |
1.1.0 版本现处于 Beta 阶段 | |
And version 1.1.0 is now in beta, | |
37 | |
00:02:03,290 --> 00:02:06,710 | |
您可以使用最新的 API 发布应用 | |
which means you can go to production with the most up-to-date APIs. | |
38 | |
00:02:08,003 --> 00:02:10,380 | |
在开始之前 务必注意 | |
Before we jump in, it’s important to note | |
39 | |
00:02:10,464 --> 00:02:13,842 | |
使用手机时可以完全访问屏幕 | |
that unlike phones, where you get full access to the screen, | |
40 | |
00:02:14,092 --> 00:02:17,137 | |
与之不同的是在汽车中我们提供了预定义的模板 | |
in cars, we are providing you with pre-defined templates | |
41 | |
00:02:17,220 --> 00:02:20,641 | |
这些模板是出于驾驶员安全考虑而精心设计的 | |
that were carefully built with driver safety considerations. | |
42 | |
00:02:21,224 --> 00:02:23,977 | |
我们根据应用类别 | |
Our approach is to expose relevant templates to you | |
43 | |
00:02:24,061 --> 00:02:25,937 | |
提供相关模板 | |
according to your app’s category, | |
44 | |
00:02:26,188 --> 00:02:31,026 | |
并逐渐构建一个内聚的库便于您按照自己的构想进行实现 | |
and over time, build a cohesive library that allows you to build what you want. | |
45 | |
00:02:32,027 --> 00:02:36,365 | |
我们从导航 停车和充电应用开始 | |
We are starting this journey with navigation, parking, and charging apps. | |
46 | |
00:02:37,532 --> 00:02:41,370 | |
即时通讯和媒体应用沿用现有的 Android API | |
Messaging and media apps should keep using existing Android APIs. | |
47 | |
00:02:42,079 --> 00:02:44,665 | |
如果您有兴趣将您的应用部署到汽车 | |
If you're interested in bringing your apps to cars | |
48 | |
00:02:44,748 --> 00:02:49,127 | |
但应用却不属于上述任何类别的话 请与我们联系 | |
but don’t fall into any of these categories, please reach out to us and let us know | |
49 | |
00:02:49,211 --> 00:02:52,214 | |
并描述您希望将来在 Car App Library 中看到的功能 | |
what you’d like to see in the Car App Library in the future. | |
50 | |
00:02:53,674 --> 00:02:56,551 | |
现在我们已了解 Car App Library 可以提供的功能 | |
Now that we know what the Car App Library can offer you, | |
51 | |
00:02:56,635 --> 00:02:58,845 | |
我们来看看它的架构吧 | |
let’s have a look at the architecture. | |
52 | |
00:02:59,429 --> 00:03:01,348 | |
在车内启动应用时 | |
When your app is launched in the car, | |
53 | |
00:03:01,431 --> 00:03:05,602 | |
搭载 Android Auto 或 Automotive OS 的主机应用 | |
a host application running on either Android Auto or Automotive OS | |
54 | |
00:03:05,686 --> 00:03:09,189 | |
会连接到需要扩展的 CarAppService | |
will connect to a CarAppService that you will extend. | |
55 | |
00:03:09,606 --> 00:03:13,110 | |
在您的 CarAppService 类中 您需要覆写 onCreateSession | |
In your CarAppService, you will override onCreateSession, | |
56 | |
00:03:13,193 --> 00:03:15,821 | |
该方法会返回一个 Session 实例 | |
which returns a session instance corresponding to | |
57 | |
00:03:15,904 --> 00:03:17,739 | |
它对应主机的当前连接 | |
the current connection to the host. | |
58 | |
00:03:18,407 --> 00:03:21,410 | |
Session 负责覆写 onCreateScreen | |
The session is responsible for returning the screen instance | |
59 | |
00:03:21,493 --> 00:03:26,289 | |
进而返回要在应用首次启动时使用的 Screen 实例 | |
to use the first time the app is started by overriding onCreateScreen. | |
60 | |
00:03:26,915 --> 00:03:30,711 | |
然后 所有 Screen 类都会实现 onGetTemplate | |
Then, each of your screen classes will implement onGetTemplate, | |
61 | |
00:03:30,794 --> 00:03:33,296 | |
该方法会返回 Template 对象 | |
which returns a template object representing | |
62 | |
00:03:33,380 --> 00:03:36,591 | |
表示要在车载屏幕上显示的界面状态 | |
the state of the UI to display in the car screen. | |
63 | |
00:03:37,300 --> 00:03:40,762 | |
然后系统会将 Template 反馈给主机应用 | |
The template will be then fed back to the host application, | |
64 | |
00:03:40,846 --> 00:03:42,931 | |
主机应用将为您呈现界面 | |
which will render the UI for you. | |
65 | |
00:03:43,223 --> 00:03:47,227 | |
如果使用 Android Auto 您会发现所有车辆拥有相同的观感 | |
With Android Auto, you will find the same look and feel across all vehicles, | |
66 | |
00:03:47,561 --> 00:03:51,565 | |
而如果使用 Android Automotive OS 您会发现呈现的界面 | |
and with Android Automotive OS, you will find the rendered UI influenced | |
67 | |
00:03:51,648 --> 00:03:54,609 | |
会受到 OEM 自定义的影响 | |
by OEM customizations, so your app will feel | |
68 | |
00:03:54,693 --> 00:03:59,364 | |
因此您无需花费额外精力即可使应用于所搭载的车辆风格一致 | |
like it belongs in that specific car without any extra effort on your part. | |
69 | |
00:04:00,198 --> 00:04:03,326 | |
我之前提过使用 Car App Library 时 | |
As I mentioned previously, when using the Car App Library, | |
70 | |
00:04:03,577 --> 00:04:05,787 | |
需要为应用声明类别 | |
you need to declare a category for your app | |
71 | |
00:04:05,871 --> 00:04:08,832 | |
比如导航 充电或停车 | |
out of either navigation, charging, or parking, | |
72 | |
00:04:08,957 --> 00:04:12,794 | |
以便可以访问该类别的相应模板 | |
which will give you access to the corresponding templates for that category. | |
73 | |
00:04:13,462 --> 00:04:16,256 | |
所有应用都可以访问前七个模板 | |
All apps have access to the top seven templates, | |
74 | |
00:04:16,339 --> 00:04:19,301 | |
而导航 停车和充电应用 | |
while navigation and parking and charging apps | |
75 | |
00:04:19,509 --> 00:04:22,262 | |
则拥有针对其用例的特定模板 | |
have specific templates for their use case. | |
76 | |
00:04:22,512 --> 00:04:26,016 | |
请务必告知我们 | |
Again, please do let us know what templates and categories | |
77 | |
00:04:26,099 --> 00:04:27,809 | |
您希望将来看到哪些模板和类别 | |
you’d like to see in the future. | |
78 | |
00:04:28,226 --> 00:04:32,397 | |
接下来 Jay 会向大家介绍代码并展示一款简单的汽车应用 | |
Now, Jay will walk you through the code and show you an example of a simple car app. | |
79 | |
00:04:34,107 --> 00:04:36,943 | |
在这一部分我们将通过构建简单的 HelloWorld 应用 | |
In this section, we will learn about the Car App Library | |
80 | |
00:04:37,027 --> 00:04:39,070 | |
来了解 Car App Library | |
by building a simple HelloWorld app. | |
81 | |
00:04:41,698 --> 00:04:43,408 | |
我们从代码结构开始 | |
We start with the code structure. | |
82 | |
00:04:43,825 --> 00:04:45,994 | |
我们的代码库有四个组件 | |
Our code base has four components. | |
83 | |
00:04:46,745 --> 00:04:48,830 | |
首先是手机应用组件 | |
The first is our phone app component, | |
84 | |
00:04:48,997 --> 00:04:52,459 | |
其中包含手机应用所需的代码和资源 | |
where the code and resources needed for the phone app will be placed. | |
85 | |
00:04:53,752 --> 00:04:56,379 | |
其次是通用汽车应用组件 | |
Then, we have the common car app component | |
86 | |
00:04:56,463 --> 00:04:59,257 | |
包含所有汽车应用代码和资源 | |
that contains all the car app code and resources. | |
87 | |
00:05:00,717 --> 00:05:03,428 | |
该组件可在 Android Auto | |
This component will be shared between the Android Auto | |
88 | |
00:05:03,720 --> 00:05:05,472 | |
和 Automotive OS 构建目标之间共享 | |
and Automotive OS build targets. | |
89 | |
00:05:06,640 --> 00:05:10,268 | |
接下来是 Android Auto 和 Automotive OS 组件 | |
Next, we have the Android Auto and Automotive OS components, | |
90 | |
00:05:10,435 --> 00:05:14,064 | |
这些组件仅包含 AndroidManifest 和 build.gradle 文件 | |
which just contain the AndroidManifest and the build.gradle files. | |
91 | |
00:05:15,273 --> 00:05:17,984 | |
了解该结构后 我们来编写代码 | |
With this structure in mind, let's jump into the code. | |
92 | |
00:05:18,568 --> 00:05:21,530 | |
我们需要在 build.gradle 文件中定义依赖项 | |
Let's define the dependencies in our build.gradle files. | |
93 | |
00:05:22,656 --> 00:05:27,410 | |
我们的应用依赖 Car App Library | |
For our app, we will depend on the 1.1.0 beta 01 version | |
94 | |
00:05:27,494 --> 00:05:28,870 | |
1.1.0 Beta 01 版本 | |
of the Car App Library. | |
95 | |
00:05:30,622 --> 00:05:33,625 | |
这些是 Android Auto 构建目标的依赖项 | |
These are the dependencies for the Android Auto build target. | |
96 | |
00:05:34,084 --> 00:05:36,503 | |
我们有共享的 Car App Library 依赖项 | |
We have the shared Car App Library dependency | |
97 | |
00:05:36,753 --> 00:05:39,840 | |
也有 Android Auto 特定依赖项 | |
as well as the Android Auto specific dependency. | |
98 | |
00:05:41,049 --> 00:05:43,343 | |
这些是 Automotive OS 依赖项 | |
These are the Automotive OS dependencies. | |
99 | |
00:05:43,552 --> 00:05:46,680 | |
请注意 共享库依赖项保持不变 | |
Notice that the shared library dependency stays the same, | |
100 | |
00:05:47,138 --> 00:05:50,225 | |
但同时我们有 Automotive OS 特定依赖项 | |
but now, we have the Automotive OS specific dependency. | |
101 | |
00:05:51,726 --> 00:05:55,313 | |
设置依赖项后即可编写同时适用于 Android Auto | |
After setting the dependencies, we can write the main car app logic | |
102 | |
00:05:55,480 --> 00:05:58,817 | |
和 Automotive OS 的主要汽车应用逻辑 | |
that works in both Android Auto and Automotive OS. | |
103 | |
00:05:59,484 --> 00:06:02,028 | |
首先 我们来创建 CarAppService 类 | |
First, we create our CarAppService class. | |
104 | |
00:06:02,279 --> 00:06:04,614 | |
这个类是应用和主机之间 | |
This class is the main bridge of communication | |
105 | |
00:06:04,698 --> 00:06:06,533 | |
通信的主要桥梁 | |
between our app and the host. | |
106 | |
00:06:07,534 --> 00:06:11,955 | |
在 onCreateSession 方法中我们返回 HelloWorldSession 对象 | |
In onCreateSession method, we return a HelloWorldSession object, | |
107 | |
00:06:12,038 --> 00:06:13,456 | |
相关内容我们很快就会讲到 | |
which we will go over soon. | |
108 | |
00:06:14,916 --> 00:06:17,961 | |
在我们自己的 Service 中需要实现一个 HostValidator 方法 | |
In our service, we also create a host validator | |
109 | |
00:06:18,169 --> 00:06:21,590 | |
用来检查与我们的服务绑定的主机是否可信 | |
to check if the host that binds to our service can be trusted. | |
110 | |
00:06:22,883 --> 00:06:27,053 | |
我们使用默认主机白名单 但您可以根据需要添加新主机 | |
We use the default host whitelist here, but you can add new hosts if needed. | |
111 | |
00:06:28,263 --> 00:06:30,640 | |
接下来我们来创建 HelloWorldSession | |
Next, we create HelloWorldSession. | |
112 | |
00:06:31,683 --> 00:06:35,520 | |
Session 是一个对象 它在车载屏幕中打开应用时 | |
Session is the object that returns the first screen to be shown | |
113 | |
00:06:35,604 --> 00:06:37,689 | |
可返回要显示的首个界面 | |
when the app is opened in the car screen. | |
114 | |
00:06:38,690 --> 00:06:40,661 | |
在这里 我们返回 HelloWorldScreen | |
Here, we return HelloWorldScreen, | |
115 | |
00:06:40,890 --> 00:06:42,861 | |
在后面的幻灯片中我们会重新讨论 | |
which we will revisit in later slides. | |
116 | |
00:06:44,446 --> 00:06:48,158 | |
Session 在生命周期及配置发生变更时 | |
Session also receives intents as well as callbacks on lifecycle | |
117 | |
00:06:48,241 --> 00:06:49,826 | |
接收 intent 和回调 | |
and configuration changes. | |
118 | |
00:06:51,453 --> 00:06:53,622 | |
接下来 我们来创建 HelloWorldScreen | |
Next, we create HelloWorldScreen. | |
119 | |
00:06:54,122 --> 00:06:57,292 | |
Screen 对象包含我们希望在车载屏幕中 | |
A screen object contains the template and the metadata | |
120 | |
00:06:57,375 --> 00:06:59,419 | |
显示的模板和元数据 | |
that we want to show in the car screen. | |
121 | |
00:07:00,420 --> 00:07:04,299 | |
我们在 onGetTemplate 方法中构建并返回 Template 对象 | |
We construct and return a template object in onGetTemplate method. | |
122 | |
00:07:05,967 --> 00:07:09,220 | |
此外 Screen 可以访问 ScreenManager 对象 | |
Also, screen has access to the ScreenManager object | |
123 | |
00:07:09,471 --> 00:07:11,806 | |
您可以使用该对象推送和弹出屏幕 | |
that you can use to push and pop screens. | |
124 | |
00:07:12,390 --> 00:07:15,060 | |
我们将在下一张幻灯片中了解 ScreenManager 的工作原理 | |
We will see how ScreenManager works in the next slide. | |
125 | |
00:07:16,895 --> 00:07:20,440 | |
我们将创建包含一行文本的非常简单的列表模板 | |
We will create a very simple list template with one row of text. | |
126 | |
00:07:21,274 --> 00:07:23,068 | |
首先 我们来创建一个 row 对象 | |
First, we create the row object. | |
127 | |
00:07:24,152 --> 00:07:27,238 | |
当用户点按该行时我们会使用 ScreenManager | |
When the user taps on the row, we use the ScreenManager | |
128 | |
00:07:27,322 --> 00:07:28,657 | |
推送进入到 MyNextScreen | |
to push the next screen. | |
129 | |
00:07:30,659 --> 00:07:35,538 | |
然后我们为该行创建列表并创建一个 ListTemplate 对象 | |
Then, we create the list for the row and create a list template. | |
130 | |
00:07:38,166 --> 00:07:42,212 | |
在接下来的几张幻灯片中我们将展示可以使用该库执行的一些操作 | |
For the next few slides, we will show a few things you can do with the library. | |
131 | |
00:07:43,004 --> 00:07:45,799 | |
有关库功能的全面演示 | |
For a comprehensive walkthrough of the library features, | |
132 | |
00:07:46,132 --> 00:07:49,469 | |
请参阅 Car App Library 开发者文档 | |
please refer to the Car App Library developer documentation. | |
133 | |
00:07:51,012 --> 00:07:54,891 | |
用户轻触该行时 我们会更新 row 的文字内容 | |
Here, when the user taps on the row, we update the row text. | |
134 | |
00:07:56,017 --> 00:07:59,854 | |
invalidate 方法的调用 会通知主机屏幕需要更新 | |
The invalidate call notifies the host that the screen needs to be updated. | |
135 | |
00:08:01,898 --> 00:08:06,236 | |
显示一个 toast 可以使用 CarToast 类 | |
In order to show a toast, you can use the CarToast class, as shown here. | |
136 | |
00:08:06,945 --> 00:08:10,031 | |
其使用模式与常规的 Toast 类相同 | |
The usage pattern is the same as the regular Toast class. | |
137 | |
00:08:11,658 --> 00:08:14,786 | |
如果要请求权限 比如位置权限 | |
To request permissions, such as the location permission, | |
138 | |
00:08:15,036 --> 00:08:17,706 | |
可以使用 carContext.requestPermissions 方法 | |
you can use carContext.requestPermissions method. | |
139 | |
00:08:18,832 --> 00:08:20,959 | |
在 Android Auto 中调用此方法 | |
In Android Auto, calling this method | |
140 | |
00:08:21,042 --> 00:08:24,087 | |
会在手机屏幕弹出权限请求窗口 | |
will show the permission request pop-up in the phone screen. | |
141 | |
00:08:25,547 --> 00:08:29,342 | |
在 Automotive OS 中弹出窗口则显示在车载屏幕上 | |
In Automotive OS, the pop-up will be shown in the car screen. | |
142 | |
00:08:30,552 --> 00:08:32,554 | |
在回调中 您会得到 | |
In the callback, you will have the list | |
143 | |
00:08:32,637 --> 00:08:35,473 | |
可操作的已批准和已拒绝权限的列表 | |
of approved and rejected permissions that you can act on. | |
144 | |
00:08:37,058 --> 00:08:40,937 | |
要发送通知请构建常规的的 Notification 对象 | |
To send a notification, construct a normal notification object, | |
145 | |
00:08:41,187 --> 00:08:43,898 | |
可以选择使用 CarAppExtender 进行扩展 | |
optionally extended with CarAppExtender, | |
146 | |
00:08:44,357 --> 00:08:46,776 | |
然后使用 CarNotificationManager 发送通知对象 | |
and send it with CarNotificationManager. | |
147 | |
00:08:47,610 --> 00:08:52,741 | |
在 Android Auto 中 CarAppExtender 可用于 | |
In Android Auto, CarAppExtender allows you to differentiate the notification style | |
148 | |
00:08:52,824 --> 00:08:55,493 | |
区分手机和车载屏幕之间不同的通知样式和内容 | |
and content between the phone and the car screen. | |
149 | |
00:08:56,828 --> 00:08:59,456 | |
在 Android Auto 和 Automotive OS 中 | |
In both Android Auto and Automotive OS, | |
150 | |
00:08:59,581 --> 00:09:02,250 | |
当通知显示在车载屏幕上时 | |
when the notification is displayed in the car screen, | |
151 | |
00:09:02,375 --> 00:09:04,836 | |
CarAppExtender 中设置的任何内容 | |
any content set in the CarAppExtender | |
152 | |
00:09:04,919 --> 00:09:07,964 | |
都会替换等效的通知内容 | |
will override the equivalent notification content. | |
153 | |
00:09:08,506 --> 00:09:10,842 | |
恭喜完成代码部分 | |
Congratulations for finishing the code section. | |
154 | |
00:09:11,342 --> 00:09:12,343 | |
我们即将大功告成 | |
We're almost there. | |
155 | |
00:09:13,136 --> 00:09:16,139 | |
接下来我们将介绍 | |
In the next section, we will go over the Manifest files | |
156 | |
00:09:16,264 --> 00:09:19,142 | |
Android Auto 和 Automotive OS 构建目标的清单文件 | |
for Android Auto and Automotive OS build targets. | |
157 | |
00:09:20,727 --> 00:09:22,645 | |
在 Android Auto 清单文件中 | |
In the Android Auto Manifest file, | |
158 | |
00:09:22,729 --> 00:09:25,607 | |
我们会在 application 元素中添加此元数据 | |
we add this metadata in our application element. | |
159 | |
00:09:26,649 --> 00:09:30,570 | |
通过此元数据 Android Auto 会将您的应用标记为汽车应用 | |
This metadata allows Android Auto to identify your app as a car app. | |
160 | |
00:09:32,322 --> 00:09:36,034 | |
我们还将相应的 XML 文件放在 Resources 目录中 | |
We also place the corresponding XML file in our Resources directory. | |
161 | |
00:09:37,494 --> 00:09:40,705 | |
接下来 我们为应用定义最低汽车 API 级别 | |
Next, we define the minimum car API level for our app. | |
162 | |
00:09:41,623 --> 00:09:46,211 | |
如果最低 API 级别较高则意味着我们可以使用最新的库功能 | |
Higher minimum API level means that we can use the latest library features, | |
163 | |
00:09:46,836 --> 00:09:49,422 | |
但部分主机可能不支持该 API 级别 | |
but some hosts may not support the API level. | |
164 | |
00:09:50,924 --> 00:09:53,676 | |
发生这种情况时 主机会显示一条消息 | |
When that happens, the host will display a message | |
165 | |
00:09:53,760 --> 00:09:54,969 | |
通知更新主机应用 | |
to update the host app. | |
166 | |
00:09:56,554 --> 00:09:59,265 | |
由于我们仅使用基本的库功能 | |
Since we are only using basic library features, | |
167 | |
00:09:59,432 --> 00:10:00,975 | |
选择 API 级别 1 即可 | |
we can leave it at one. | |
168 | |
00:10:02,018 --> 00:10:05,772 | |
接下来 我们在 application 元素中声明 CarAppService | |
Then, we declare our CarAppService in the application element. | |
169 | |
00:10:07,065 --> 00:10:11,736 | |
请注意 在 intent-filter 元素中我们将服务声明为 CarAppService | |
Notice that, in the intent-filter element, we declare our service as a CarAppService | |
170 | |
00:10:12,445 --> 00:10:14,989 | |
并将汽车应用的类别声明为泊车应用 | |
and also our car app's category as a parking app. | |
171 | |
00:10:16,533 --> 00:10:20,787 | |
此处声明的类别未来将会用于 Play 商店应用审核流程 | |
The category declared here will later be used in the Play Store app review process | |
172 | |
00:10:20,995 --> 00:10:25,416 | |
以检查应用是否符合特定类别的汽车应用质量指南 | |
to check if our app meets the category-specific car app quality guidelines. | |
173 | |
00:10:26,334 --> 00:10:28,962 | |
Automotive OS 清单看起来有些不同 | |
The Automotive OS Manifest looks somewhat different. | |
174 | |
00:10:30,004 --> 00:10:34,384 | |
我们在其中声明了在汽车应用中使用和未使用的各种功能 | |
Here, we declare various features that we are and are not using in our car app. | |
175 | |
00:10:35,718 --> 00:10:39,848 | |
务必将 Wi-Fi 和摄像头等功能声明为 false | |
Declaring features such as Wi-Fi and camera as false is important. | |
176 | |
00:10:41,641 --> 00:10:45,812 | |
否则 应用可能无法在不支持此类功能的汽车中使用 | |
Otherwise, our app may not show up in cars that do not support such features. | |
177 | |
00:10:47,313 --> 00:10:50,150 | |
同 Android Auto 一样我们也在 Automotive OS 中添加了元数据 | |
As we did for Android Auto, we add the metadata | |
178 | |
00:10:50,233 --> 00:10:53,361 | |
以便其可以将应用识别为汽车应用 | |
so Automotive OS can recognize our app as a car app | |
179 | |
00:10:53,736 --> 00:10:56,447 | |
并声明最低 API 级别 | |
and also declare the minimum API level. | |
180 | |
00:10:57,448 --> 00:11:00,660 | |
我们以相同的方式声明汽车应用服务 | |
Again, our car app service is declared in the same way. | |
181 | |
00:11:02,203 --> 00:11:06,040 | |
最后 我们来声明特定于 Automotive OS 的 Activity | |
Lastly, we declare an activity specific to Automotive OS. | |
182 | |
00:11:07,041 --> 00:11:09,586 | |
请留意 distractionOptimized 元数据 | |
Notice the distractionOptimized metadata. | |
183 | |
00:11:10,336 --> 00:11:13,923 | |
要想应用在用户驾驶时运行必须用到此元数据 | |
This is needed for our app to work while the user is driving. | |
184 | |
00:11:15,383 --> 00:11:16,301 | |
就是这样 | |
That is it. | |
185 | |
00:11:16,384 --> 00:11:20,847 | |
现在您可以构建同时在 Android Auto 和 Automotive OS 中运行的应用 | |
Now you can build an app that runs in both Android Auto and Automotive OS. | |
186 | |
00:11:21,931 --> 00:11:23,892 | |
除库功能之外 | |
In addition to the library features, | |
187 | |
00:11:24,225 --> 00:11:27,061 | |
汽车应用还可以通过集成语音功能得到体验的提升 | |
your car app can benefit from voice integration. | |
188 | |
00:11:28,313 --> 00:11:30,356 | |
通过语音集成 驾驶员们可以 | |
Voice integration allows the driver | |
189 | |
00:11:30,440 --> 00:11:33,276 | |
在不分心的情况下与应用进行交互 | |
to interact with your app without being distracted | |
190 | |
00:11:33,860 --> 00:11:36,905 | |
还可以通过多种方式扩展应用功能 | |
and can also extend your app's functionality in many ways. | |
191 | |
00:11:39,657 --> 00:11:42,285 | |
您可以在 Session 对象的 onCreateScreen | |
You can receive intents from the Voice Assistant | |
192 | |
00:11:42,368 --> 00:11:46,581 | |
和 onNewIntent 方法中接收来自语音助理的 Intent | |
in your session objects onCreateScreen and onNewIntent methods. | |
193 | |
00:11:47,999 --> 00:11:51,628 | |
如果您正在构建导航应用且支持导航 Intent | |
If you’re building a navigation app and support navigation intents, | |
194 | |
00:11:52,086 --> 00:11:54,505 | |
则可能会收到来自语音查询的 Intent | |
you may receive intents from the voice queries. | |
195 | |
00:11:55,215 --> 00:11:58,301 | |
我们将在下一张幻灯片中展示如何处理此 Intent | |
We will show you how to handle this intent in the next slide. | |
196 | |
00:11:59,302 --> 00:12:04,557 | |
您的应用也可能会收到来自 App Actions 的内置和自定义 Intent | |
In addition, your app may receive built-in and custom intents from Android App Actions, | |
197 | |
00:12:04,933 --> 00:12:06,184 | |
如同手机应用一样 | |
just like your phone app. | |
198 | |
00:12:07,560 --> 00:12:10,563 | |
如需了解更多信息请参阅幻灯片中的链接 | |
For more information, please refer to the link in the slide. | |
199 | |
00:12:11,648 --> 00:12:15,485 | |
我们正在处理在 onNewIntent 方法中收到的 Intent | |
Here, we are handling the intent that we received in onNewIntent method. | |
200 | |
00:12:16,527 --> 00:12:21,032 | |
可以使用同样的方式处理 onCreateScreen 方法中收到的 Intent | |
The intent received in onCreateScreen method can be handled in the same manner. | |
201 | |
00:12:21,991 --> 00:12:25,119 | |
如果 Intent 的 action 值是 CarContext.ACTION_NAVIGATE | |
If the intent action is CarContext.ACTION_NAVIGATE, | |
202 | |
00:12:25,536 --> 00:12:28,998 | |
我们会解析查询字符串并将其传递给推送的 | |
we parse the query string, which we pass to the constructor | |
203 | |
00:12:29,082 --> 00:12:31,417 | |
MyNavigationScreen 构造函数 | |
of MyNavigationScreen that we push. | |
204 | |
00:12:32,252 --> 00:12:36,506 | |
有关 Intent 的确切格式请参阅 CarContext 开发者文档 | |
See the car context developer documentation for the exact format of the intent. | |
205 | |
00:12:37,548 --> 00:12:42,053 | |
小结一下 我们构建了一个 HelloWorld 应用 编写了通用代码 | |
So far, we wrote our HelloWorld app with the common code, dependencies, | |
206 | |
00:12:42,136 --> 00:12:46,266 | |
依赖项和清单文件 并将其与语音助理集成 | |
and the Manifest files, and integrated with the Voice Assistant. | |
207 | |
00:12:47,809 --> 00:12:49,978 | |
接下来该运行应用啦 | |
Now is the time to see our app in action. | |
208 | |
00:12:50,770 --> 00:12:52,647 | |
接下来 我将带您了解 | |
In the next section, we will explain | |
209 | |
00:12:52,730 --> 00:12:56,943 | |
如何在 Android Auto 和 Automotive OS 模拟器中运行汽车应用 | |
how to run a car app in Android Auto and Automotive OS emulators. | |
210 | |
00:12:59,362 --> 00:13:01,322 | |
幻灯片中的链接提供了 | |
The link in the slide has instructions | |
211 | |
00:13:01,406 --> 00:13:06,160 | |
如何下载和运行 Android Auto 和 Automotive OS 模拟器 | |
on how to download and run the emulators in Android Auto and Automotive OS. | |
212 | |
00:13:08,162 --> 00:13:11,791 | |
确保应用设定了 Android Auto 为构建目标 | |
Make sure you build and install your car app’s Android Auto build target | |
213 | |
00:13:11,874 --> 00:13:14,877 | |
以便可以在桌面车机 (DHU) 中运行 | |
on the phone to run it in the desktop head unit. | |
214 | |
00:13:15,628 --> 00:13:20,633 | |
在汽车模拟器中运行的应用要设定 Automotive OS 为构建目标 | |
Similarly, build and install Automotive OS build target in automotive emulators. | |
215 | |
00:13:21,592 --> 00:13:25,972 | |
在模拟器中运行应用时还可以看到仪表盘屏幕 | |
When you run your app in the emulators, you can also see the cluster display, | |
216 | |
00:13:26,389 --> 00:13:29,809 | |
其中可能会显示导航或其他相关信息 | |
which may show navigation or other relevant information. | |
217 | |
00:13:30,935 --> 00:13:34,147 | |
如果应用集成了语音助理 | |
Also, you can test the voice commands in the emulators | |
218 | |
00:13:34,439 --> 00:13:37,025 | |
则还可以在模拟器中测试语音命令 | |
if your app is integrated with the Voice Assistant. | |
219 | |
00:13:38,443 --> 00:13:40,987 | |
最后一部分关于如何发布应用 | |
This last section is about publishing your app. | |
220 | |
00:13:41,654 --> 00:13:45,116 | |
此过程与常规应用发布过程非常相似 | |
The process is very similar to the regular app publishing process, | |
221 | |
00:13:45,450 --> 00:13:47,493 | |
我们只指出其中的不同之处 | |
so we will only note the differences. | |
222 | |
00:13:48,786 --> 00:13:51,497 | |
要在 Play 商店管理中心提交汽车应用 | |
To submit your car app in the Play Store console, | |
223 | |
00:13:51,789 --> 00:13:55,251 | |
请单击 Setup Advanced Settings 和 Release Types | |
click Setup, Advanced Settings, and Release Types. | |
224 | |
00:13:56,586 --> 00:13:59,714 | |
根据汽车应用的构建目标 | |
Select Android Auto or Android Automotive OS, | |
225 | |
00:13:59,922 --> 00:14:02,050 | |
选择 Android Auto 或 Android Automotive OS | |
depending on your car app’s build target. | |
226 | |
00:14:02,842 --> 00:14:07,430 | |
上传 APK 时为 Android Auto 选择 Standard Release Type | |
When uploading your APK, select Standard Release Type for Android Auto | |
227 | |
00:14:08,139 --> 00:14:10,933 | |
为 Automotive OS 选择 Automotive OS Only | |
and Automotive OS Only for Automotive OS. | |
228 | |
00:14:12,018 --> 00:14:14,854 | |
提交后 根据汽车应用质量指南 | |
After submission, there may be additional reviews | |
229 | |
00:14:14,937 --> 00:14:17,065 | |
可能需要进行额外审核 | |
based on car app quality guidelines. | |
230 | |
00:14:18,399 --> 00:14:22,862 | |
审核完成后 您会收到一封附有审核结果的通知电子邮件 | |
When the review is complete, you will receive a notification email with the result. | |
231 | |
00:14:24,072 --> 00:14:26,783 | |
希望大家对构建汽车应用充满信心 | |
I hope you will feel confident about building car apps | |
232 | |
00:14:26,949 --> 00:14:30,620 | |
相信自己的应用能够帮助路上数百万汽车用户 | |
and reaching out to millions of users on the road that need your app. | |
233 | |
00:14:31,913 --> 00:14:34,457 | |
为帮助大家制作优秀的应用 | |
To help you make great apps, we are working hard | |
234 | |
00:14:34,540 --> 00:14:37,043 | |
我们正在努力添加更多模板和类别 | |
to add more templates and categories. | |
235 | |
00:14:38,503 --> 00:14:41,339 | |
我们还致力于为 Automotive OS 汽车应用 | |
We’re also working on paid app and in-app purchase flows | |
236 | |
00:14:41,422 --> 00:14:43,257 | |
提供付费应用和应用内购买流程 | |
for Automotive OS car apps. | |
237 | |
00:14:45,301 --> 00:14:48,513 | |
请与我们联系告知我们您希望将来 | |
Please reach out to us and let us know what you would like to see | |
238 | |
00:14:48,596 --> 00:14:50,556 | |
在 Car App Library 中看到的功能 | |
in the car app library in the future. | |
239 | |
00:14:51,641 --> 00:14:54,143 | |
最后 幻灯片中这些资源 | |
Lastly, here are resources that contain | |
240 | |
00:14:54,227 --> 00:14:58,147 | |
会更全面更详细地介绍如何构建汽车应用 | |
more comprehensive and detailed information about building a car app. | |
241 | |
00:14:59,065 --> 00:15:00,149 | |
感谢收看 | |
Thanks for watching. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment