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.
我正在构建一个用于获取互联网数据并将其呈现为列表的 android 应用程序。数据每分钟都在变化,所以我做了一个服务,并使用 Timer 以间隔加载数据。
我的问题是:
有任何想法吗?
onPause
onResume
详细说明 1:我知道您说的是“应用程序”,而不是“特定活动”,但您最好的选择是使用Activity.onPauseand Activity.onResume。如果有的话,您可以添加一个短暂的延迟,以便在 onPause 之后紧跟 onResume 时不会发生任何事情。
Activity.onPause
Activity.onResume