开发者

start/stop android service based on call events

开发者 https://www.devze.com 2023-02-18 07:50 出处:网络
how can i start/stop a specific service based on the following: user A call user B ( the trigger is user B answer the phone and service stopped when ca开发者_运维问答ll is ended )

how can i start/stop a specific service based on the following:

  1. user A call user B ( the trigger is user B answer the phone and service stopped when ca开发者_运维问答ll is ended )
  2. user B call user A ( the trigger is user A answer the phone and service stopped when call is ended )

i want to calculate the call duration of the call and store the result in database.

regards


The calculation of the call duration is already done for you. Use the CallLog content provider, please.

Even if for some strange reason using the official call log is not what you want, you do not need a service. Set up a manifest-registered BroadcastReceiver for ACTION_PHONE_STATE_CHANGED and store the start/stop times in the database. Do not have a Service hanging out in memory for the sole purpose of watching time tick by.

But, please, just use the CallLog, since the OS is doing this work for you, and you don't waste the user's battery doing duplicate work.

0

精彩评论

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

关注公众号