开发者

Handle Timer when incoming calls & SMS

开发者 https://www.devze.com 2023-02-16 01:11 出处:网络
I have started multiple Timers on the same screen. W开发者_运维百科hen an incoming call or SMS comes, how can I handle the functioning of the timers.

I have started multiple Timers on the same screen.

W开发者_运维百科hen an incoming call or SMS comes, how can I handle the functioning of the timers. The timer should continue running when the incoming call is being attended by the user.

Kindly provide your inputs/sample code.


The problem with Timers is that they depend on the current Activity state, so if the activity has been completely obscured (like when a call arrives) it's onStop() method will be called, and Android doesn't guarantee that your app will continue running from that point.

The best solution to this is to use services. Here you have official Services guide.

0

精彩评论

暂无评论...
验证码 换一张
取 消