Android activity 在后台?

Android activity in background?

我正在开发一个应用程序,它从 activity A(主)开始,通过登录到 activity B,然后是 C,依此类推...

现在,需要在登录时启动某种算法,该算法在应用程序的整个持续时间内循环旋转。是否可以创建一个与可见活动堆栈并行运行(在后台)的 activity?或者还有其他你知道的作案手法吗?

您要找的是 Service。根据文档:

A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

有关示例和更多信息,请参阅提供的 link。