just remove startManagingCursor and call the close() method on the cursor when you've finished reading from it
On Oct 13, 5:02 am, Nemat <nemate...@gmail.com> wrote: > @Roman > > But How would we get the state when the call is received?I mean call > duration means the difference of the time when call is received and > the time when the call is disconnected.OFFHOOK is the state when caLL > is placed.So we should be notified when the call is received.How can > we get that? > > @nEx.Software > > if its not possible with service then it is of no use for me. > > Anyways is there any way to read the call-log in service? > > On Oct 12, 11:08 pm, "nEx.Software" <email.nex.softw...@gmail.com> > wrote: > > > You are getting the error on startManagingCursor because that method > > does not exist in a Service. > > Leave that out and make sure you close the cursor when you are done > > with it. > > > On Oct 12, 11:00 am, "Roman ( T-Mobile USA)" <roman.baumgaert...@t- > > > mobile.com> wrote: > > > You should be able to measure the time between multiple > > > onCallStateChanged events. > > > > In case of an outgoing call the state would switch from IDLE to > > > CAll_STATE_OFFHOOK to to IDLE again. > > > > -- > > > Roman Baumgaertner > > > Sr. SW Engineer-OSDC > > > ·T· · ·Mobile· stick together > > > The views, opinions and statements in this email are those of the > > > author solely in their individual capacity, and do not necessarily > > > represent those of T-Mobile USA, Inc. > > > > On Oct 12, 3:14 am, Nemat <nemate...@gmail.com> wrote: > > > > > 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?- > > > > Hide quoted text - > > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---