Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们不能从服务启动活动吗?如果是这样,服务是否会在单独的线程中继续在后台运行,而在前台启动的活动是否会作为单独的线程?
我们不能从服务启动活动吗?
您可以调用startActivity()aService或任何其他Context.
startActivity()
Service
Context
如果是这样,服务是否会在单独的线程中继续在后台运行,而在前台启动的活动是否会作为单独的线程?
在 Java 中,对象不在线程上运行。方法在线程上运行。活动是从服务启动的这一事实根本不会影响这一点。默认情况下,几乎所有带有 anActivity和 aService的东西都发生在主应用程序线程上,而且这也不会因为Service启动了Activity.
Activity