Hi,

I am calling a phone number through intent..like

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:123456"));
startActivityForResult(intent, 1);

how can i find the call duration means whenever the person has been
answered the call and whenever he dropped the call... for that i tried
like this...but i can be able to find out the when the person ended
the call but i cannot be able to find out the time whenever the call
has been answered.

       @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            super.onCallStateChanged(state, incomingNumber);

            // Don't fire before the call was made
            if (state == TelephonyManager.CALL_STATE_OFFHOOK)
            {
                called = true;
                dialled = true;
                long startTime = System.currentTimeMillis();
Date date = new Date(startTime);
Toast.makeText(UITestActivity.this,"Call Connected: "+
date.toString(), Toast.LENGTH_SHORT).show();
            }   

  if(state == TelephonyManager.CALL_STATE_RINGING){

Toast.makeText(UITestActivity.this," RINGING ", Toast.LENGTH_SHORT).show();
            }

            // Call has ended -- now bring the activity back to front
            if (called && state == TelephonyManager.CALL_STATE_IDLE) {
                called = false;
                System.out.println("DROPPED THE CALL");
                mTelMgr.listen(this, PhoneStateListener.LISTEN_NONE);
                long endtime = System.currentTimeMillis();
                Date date = new Date(endtime);
               Toast.makeText(UITestActivity.this,"Call Disconnected:
"+ date.toString(), Toast.LENGTH_SHORT).show();
        startActivity(new Intent(UITestActivity.this, UITestActivity.class));
            }
        }



On 1/4/12, Abhilash baddam <abhilash.androiddevelo...@gmail.com> wrote:
> Hi narendra,
>
> I tried as per your suggestion thanks. But i was strucked  to find out
> whether the outgoing call has been answered.
>
>
> On 1/4/12, Narendra Bagade <bagadenaren...@gmail.com> wrote:
>> refer related content provider like call log.
>>
>> On Wed, Jan 4, 2012 at 12:26 PM, Abhilash baddam <
>> abhilash.androiddevelo...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I want to know the call duration, when I called to other number and
>>> when that call-ends. How can i get the call duration...?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-developers@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> android-developers+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>
>>
>>
>>
>> --
>> Regards,
>> Narendra
>> .
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to