get outgoing call details in background

Put your problem here if it does not fit any of the other categories.

get outgoing call details in background

Postby Nemat » Mon Oct 12, 2009 11:32 am

Hi friends,

Actually I was working to get duration of outgoing call.But I dont
find any way of doing this.Then I decided to get the details of
outgoing call from call log.


But my code works only for Activity.I want this to work with Services
because I want to get the details related to outgoing call in
background using services.What should I do to get these details in
background.I currently implement it for Activity.Here is my complete
code:
Code: Select all
public void outgoingRecord()
  {
          Cursor c = getContentResolver().query(
              android.provider.CallLog.Calls.CONTENT_URI,
              null,
              null,
              null,
              android.provider.CallLog.Calls.DATE+ " DESC");
          startManagingCursor(c);


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


// Will hold the calls, available to the cursor
ArrayList<String> callList = new ArrayList<String>();


try{
boolean moveToFirst=c.moveToFirst();
Log.d("MOVETOFIRST", "moveToFirst="+moveToFirst);


}


catch(Exception e)
{
          Log.e("MOVETOFIRSTERROR","MOVETOFIRST Error="+e.toString());


}


         String callerPhoneNumber = c.getString(numberColumn);
         int callDate = c.getInt(dateColumn);
         int callType = c.getInt(typeColumn);
         int duration=c.getInt(durationColumn);

         Log.d("CALLS", "callDate="+callDate);


             switch(callType){
              case android.provider.CallLog.Calls.INCOMING_TYPE:


                          Log.d("INCOMINGCALLLOG", "CallerPhoneNum="+
callerPhoneNumber+" "+"Duration="+duration);


                                break;
              case android.provider.CallLog.Calls.MISSED_TYPE:
                                  break;
              case android.provider.CallLog.Calls.OUTGOING_TYPE:
                             Log.d("OUTGOINGCALLLOG",
"CallerPhoneNum="+ callerPhoneNumber+" "+"Duration="+duration);
                                 break;



}


  }


I got error in " startManagingCursor(c)".


Should I use another way to do this?If yes,What would be that way?

Is there someone to solve the problems of programmers here on this forum????

Because I dont get answers of many of my last posts.....Many of you have more knowledge than me or other new programmers.They should share there knowledge by helping others.It would not only help others but enhance their knowledge also by discussing that particular topic.

I hope you dont mind it.Sorry if I am wrong........


Nemat
Nemat
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Thu Aug 21, 2008 3:16 pm
Location: Jaipur

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests