将传感器数据写入 WearableListenerService 中的文件

Writing sensor data to files in WearableListenerService

我正在从传感器收集数据并写入 WearableListenerService 中的文件。

如何在手表开机时启动服务并一直保持运行?

似乎 Android 如果清单中的配置正确,wear 会自动启动此服务。如果不是,我是否需要从 MainActivity 显式发送意图?

如何在手表开机时启动服务并一直保持运行?

按照以下步骤操作,希望它能从此文档启动您的服务:Android Wear Quickstart

Building a Watch Face Service

To create an Android project for your watch face in Android Studio:

1.) Click File > New Project and follow the steps in the Create New Project wizard until you reach the Target Android Devices page.

2.) Select the Wear option, and in the Minimum SDK option list, select the latest available (API Nougat) option. Click Next.

3.) Select Add No Activity and click Next in the two following screens.

4.) Click Finish.

Android Studio creates a project with a wear module. For more information, see Creating a Project.