Re: [android-developers] Get call duration.

2012-02-18 Thread fei ji
You can use the class called SimpleDateFormat to format the output of time.
6258 is actually counted in millis. So you have to change the millis to
seconds and output.


On Wed, Feb 15, 2012 at 3:05 PM, Jagruti Sangani <
jagruti.sang...@inextrix.com> wrote:

> Hello,
> Iam using the below code and output will give as below.
> Cursor c =
>
> context.getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI,null,
> null, null,android.provider.CallLog.Calls.DATE + " DESC");
>int total=c.getCount();
>int numberColumn =
> c.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
>int dateColumn =
> c.getColumnIndex(android.provider.CallLog.Calls.DATE);
>
>  // type can be: Incoming, Outgoing or Missed
>int typeColumn =
> c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
>int DurationColumn =
> c.getColumnIndex(android.provider.CallLog.Calls.DURATION);
>
> if(c.moveToPosition(0)){
>// c.move(1);
>String callerPhoneNumber = c.getString(numberColumn);
>String callerPhoneDate = c.getString(dateColumn);
>String TYeor = c.getString(typeColumn);
>String Duration = c.getString(DurationColumn);
>Toast.makeText(WalkieTalkieActivity.this,"type column-
> >"+TYeor ,Toast.LENGTH_SHORT).show();
>Toast.makeText(WalkieTalkieActivity.this,"duration-
> >"+Duration ,Toast.LENGTH_SHORT).show();
>Toast.makeText(WalkieTalkieActivity.this,"phone number-
> >"+callerPhoneNumber ,Toast.LENGTH_SHORT).show();
>  }
>
>
> output:
>
> type:->2
> duration->6258
> phonenumber:->1552175049
>
> But what is it that i dont know so how can i get correct output please
> tell me.If any other way then also tell me.
>
> --
> 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

[android-developers] Get call duration.

2012-02-14 Thread Jagruti Sangani
Hello,
Iam using the below code and output will give as below.
Cursor c =
context.getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI,null,
null, null,android.provider.CallLog.Calls.DATE + " DESC");
int total=c.getCount();
int numberColumn =
c.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
int dateColumn =
c.getColumnIndex(android.provider.CallLog.Calls.DATE);

  // type can be: Incoming, Outgoing or Missed
int typeColumn =
c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
int DurationColumn =
c.getColumnIndex(android.provider.CallLog.Calls.DURATION);

 if(c.moveToPosition(0)){
// c.move(1);
String callerPhoneNumber = c.getString(numberColumn);
String callerPhoneDate = c.getString(dateColumn);
String TYeor = c.getString(typeColumn);
String Duration = c.getString(DurationColumn);
Toast.makeText(WalkieTalkieActivity.this,"type column-
>"+TYeor ,Toast.LENGTH_SHORT).show();
Toast.makeText(WalkieTalkieActivity.this,"duration-
>"+Duration ,Toast.LENGTH_SHORT).show();
Toast.makeText(WalkieTalkieActivity.this,"phone number-
>"+callerPhoneNumber ,Toast.LENGTH_SHORT).show();
  }


output:

type:->2
duration->6258
phonenumber:->1552175049

But what is it that i dont know so how can i get correct output please
tell me.If any other way then also tell me.

-- 
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