Hi guys,

in this last month I've been trying to develop on Android.
I've tried a few stuff and also Nemat's code for intercepting outgoing
call details.

The only difference is that I've been using the PHONE_CALL_STATE
intents for triggering my broadcast receiver retrieving last outgoing
call details.
My problem is that when I retrieve call details from the CallLog I
always get back not the current call details but the previous one,
even when I receive the IDLE state ending the call and resetting the
phone call state.
I find this call log behavior quite fair so I think it's simply not
possible to use this way for retrieving last call details.

Any ideas, feedback??

Thanks

On Oct 14, 11:23 am, Nemat <nemate...@gmail.com> wrote:
> Thanks to all of you.....
>
> I have done it.......I removed startManagingCursor() and called the
> close method() for cursor.
>
> On Oct 13, 7:10 pm, Lazarus 101 <lazarus...@gmail.com> wrote:
>
> > just remove startManagingCursor andcallthe 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 thecallis received?I meancall
> > > duration means the difference of the time whencallis received and
> > > the time when thecallis disconnected.OFFHOOK is the state whencaLL
> > > is placed.So we should be notified when thecallis 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 thecall-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 anoutgoingcallthe 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 ofoutgoingcall.But I dont
> > > > > > find any way of doing this.Then I decided to get the details of
> > > > > >outgoingcallfromcalllog.
>
> > > > > > But my code works only for Activity.I want this to work with 
> > > > > > Services
> > > > > > because I want to get the details related tooutgoingcallin
> > > > > > 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,Outgoingor 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 -- 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

Reply via email to