PhoneStateListener - onCallStateChanged

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

PhoneStateListener - onCallStateChanged

Postby chouman » Sat Sep 27, 2008 12:24 am

I have a class CallStateListener extends PhoneStateListener
then i overwrite onCallStateChanged(int state, String incomingNumber)
which i have some logging statements but for some reason when i call
the emulator from telnet. the logging statement doesn't show up any
idea ?

here is my code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class CallStateListener extends PhoneStateListener
  3.  
  4. {
  5.  
  6.         public void onCallStateChanged(int state, String incomingNumber)
  7.  
  8.         {
  9.  
  10.                 Log.d("DEBUG", TelephonyManager.CALL_STATE_OFFHOOK + " weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee are def in here: " + state);
  11.  
  12.                
  13.  
  14.                 switch(state)
  15.  
  16.                 {
  17.  
  18.                         case TelephonyManager.CALL_STATE_IDLE:
  19.  
  20.                                 Log.d("DEBUG", "phhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhone is idle");
  21.  
  22.                                 break;
  23.  
  24.                         case TelephonyManager.CALL_STATE_OFFHOOK:
  25.  
  26.                                 Log.d("DEBUG", "phoooooooooooooooooooooooooooooooooooooon is off hook");
  27.  
  28.                                 break;
  29.  
  30.                         case TelephonyManager.CALL_STATE_RINGING:
  31.  
  32.                                 Log.d("DEBUG", "phoooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnnneeeeeeeeeeeeeeeeee is ringing");
  33.  
  34.                                 break;
  35.  
  36.                         default:
  37.  
  38.                                 Log.d("DEBUG", "The staaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaate is " + state);
  39.  
  40.                                        
  41.  
  42.                 }
  43.  
  44.         }
  45.  
  46. }
  47.  
  48.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
chouman
Developer
Developer
 
Posts: 27
Joined: Thu Jan 03, 2008 2:59 pm

Top

Postby soniya » Sat Oct 04, 2008 9:24 am

:roll:
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby plusminus » Sat Oct 04, 2008 1:46 pm

Did you register that PhoneStateListener with the TelephonyManager :?:

You couls use code similar to this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 final TelephonyManager tm = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE);
  2.  
  3.                 assert(tm != null);
  4.  
  5.                 tm.listen(this.mCallStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby TAKEphONE » Mon Nov 03, 2008 11:39 am

Hi all,

I got this into my code, and it seems to work.

Now my next challenge - I want to bring my own application to front when a call ends (so that the user can continue doing stuff with it after every call ends).

How can this be done from within the 'onCallStateChanged' function ?

TIA
TAKEphONE
Junior Developer
Junior Developer
 
Posts: 20
Joined: Mon Nov 03, 2008 11:35 am

Need help

Postby tabrej.khan » Thu Dec 04, 2008 12:03 pm

Create a new activity and call it when the phone is ringing... or at the event you want your application to wake up...

I have few more query... as above discussed... once the new Activity is start lets say the state is ringing... I started a new activity... but my activity screen goes down and the system shows the incoming phone number.

My question is:
How can I make my activity on top of system screen where it shows the incoming call.
I want my application to show some custom items on the screen when a phone rings.
User avatar
tabrej.khan
Freshman
Freshman
 
Posts: 8
Joined: Wed Jul 16, 2008 6:16 am
Location: Bangalore, Karnataka

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Alexa [Bot], MSNbot Media and 24 guests