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:
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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---