如何启动 Service 或 Job Scheduler 的性能监控以进行自动跟踪

How to start performance monitoring for Service or Job Scheduler for automatic traces

我有一个没有 activity 的模块,它的作业调度程序或服务是由 BroadcastReceiver (android.intent.action.BOOT_COMPLETED) 创建的。

根据文档,它提到了性能监控 "Starts when the app's FirebasePerfProvider ContentProvider completes its onCreate method and stops when the first activity's onResume() method is called. If the app was not cold-started by an activity (for example, by a service or broadcast receiver), no trace is generated."

那么如何为没有活动的应用启动性能监控?

您误解了文档。你指的是 this page about automatic traces.

Trace name: App start

Starts when the app's FirebasePerfProvider ContentProvider completes its onCreate method and stops when the first activity's onResume() method is called. If the app was not cold-started by an activity (for example, by a service or broadcast receiver), no trace is generated.

这告诉您 "App start" 自动跟踪的工作原理。它不会影响其余手动跟踪的工作方式。如果您的应用没有活动,那么它不会生成任何应用启动痕迹。