Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread KrcK ---
So, for example, If I want to create a new register with each incoming call in my database tableI should use a BroadcastReceiver, and if I want to do some actions in my app when appears an incoming call I should use a listener (like save some states or stop a service), is ok? On the other hand I

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread Mark Murphy
On Wed, Sep 8, 2010 at 5:55 AM, KrcK --- krc...@gmail.com wrote: So, for example, If I want to create a new register with each incoming call in my database tableI should use a BroadcastReceiver, and if I want to do some actions in my app when appears an incoming call I should use a listener

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread KrcK ---
The general idea is to create an app like incoming call log. So I have to create a new register in my database when a new call is answered or lost. To do that, I implement a BroadcastReceiver that reacts when the phone state changes. In the onReceive method, I get the TelephonyManager and through

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread Mark Murphy
On Wed, Sep 8, 2010 at 7:12 AM, KrcK --- krc...@gmail.com wrote: The general idea is to create an app like incoming call log. So I have to create a new register in my database when a new call is answered or lost. Android has a CallLog already. It's called android.provider.CallLog. To do that,

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread KrcK ---
Why not use the existing CallLog? Because I wanted to play with this API and I thougth to do that developing an app like CallLog. On the other hand, the CallLog could be deleted by the user and I want to not allow it in my app. There is also an Intent extra. Which information could I get

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread Mark Murphy
On Wed, Sep 8, 2010 at 7:36 AM, KrcK --- krc...@gmail.com wrote: There is also an Intent extra. Which information could I get through that intent? The EXTRA_STATE extra indicates the new call state. If the new state is RINGING, a second extra EXTRA_INCOMING_NUMBER provides the incoming phone

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread KrcK ---
Ok but how could I identify that I answered a call or is lost, and the duration of the call? Because I can know the current state and at what time it is produced but I do not have information about previous states. For example, I answer a call so I will receive OFFHOOK state, but when the call

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread Mark Murphy
On Wed, Sep 8, 2010 at 8:18 AM, KrcK --- krc...@gmail.com wrote: Ok but how could I identify that I answered a call or is lost, and the duration of the call? Because I can know the current state and at what time it is produced but I do not have information about previous states. The

Re: [android-developers] Re: TelephonyManager PhoneStateListener

2010-09-08 Thread KrcK ---
Ok, I think that now I know a way to do it! Thanks Mark, your help and explanations were very helpful! 2010/9/8 Mark Murphy mmur...@commonsware.com On Wed, Sep 8, 2010 at 8:18 AM, KrcK --- krc...@gmail.com wrote: Ok but how could I identify that I answered a call or is lost, and the

[android-developers] Re: TelephonyManager PhoneStateListener

2010-09-07 Thread Indicator Veritatis
I think you have lost sight of the forest for the trees. The main difference is that the Listener is just that -- a Listener. If you don't use the Listener, you have to poll for changes in phone state or create a Receiver. Often, this is a waste of time. The Listener should be preferred, unless