just want to clarify my probem a bit and provide more info

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

just want to clarify my probem a bit and provide more info

Postby chouman » Sat Sep 27, 2008 2:04 am

I am trying to register the PhoneStateListener right when the phone
boots up so I have 2 classes. One is StartAtStartUp which extends
BroadcastReceiver that listens for the COMPLETE_BOOT_UP and then this
will then register the CallStateListener which extends
PhoneStateListener. It doesn't seem to work out all that well.

I am not seeing any logging statements that I have put in
CallStateListener. Any help would be greatly appreciated!!!

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import android.content.BroadcastReceiver;
  3.  
  4. import android.content.Context;
  5.  
  6. import android.content.Intent;
  7.  
  8. import android.telephony.PhoneStateListener;
  9.  
  10. import android.telephony.TelephonyManager;
  11.  
  12. import android.util.Log;
  13.  
  14.  
  15.  
  16. import com.lumitrend.netlogger.Logger;
  17.  
  18.  
  19.  
  20. public class StartServicesAtStartUp extends BroadcastReceiver
  21.  
  22. {
  23.  
  24.         public void onReceive(Context context, Intent intent)
  25.  
  26.         {
  27.  
  28.                 Log.d("DEBUG",
  29.  
  30. "########################################################################");
  31.  
  32.                 //Intent phoneStateListener = new Intent(context,
  33.  
  34. CallStateListener.class);
  35.  
  36.                 //phoneStateListener.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  37.  
  38.                 //context.startService(phoneStateListener);
  39.  
  40.                 Log.d("DEBUG", context.getPackageName());
  41.  
  42.                 Log.d("DEBUG", context.toString());
  43.  
  44.                 TelephonyManager tManager =
  45.  
  46. (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
  47.  
  48.                 CallStateListener callStateListener = new CallStateListener();
  49.  
  50.                 tManager.listen(callStateListener,
  51.  
  52. PhoneStateListener.LISTEN_CALL_STATE);
  53.  
  54.         }
  55.  
  56.  
  57.  
  58. }
  59.  
  60.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4



Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import android.telephony.PhoneStateListener;
  3.  
  4. import android.telephony.TelephonyManager;
  5.  
  6. import android.util.Log;
  7.  
  8.  
  9.  
  10. import com.lumitrend.netlogger.Logger;
  11.  
  12.  
  13.  
  14. public class CallStateListener extends PhoneStateListener
  15.  
  16. {
  17.  
  18.         public void onCallStateChanged(int state, String incomingNumber)
  19.  
  20.         {
  21.  
  22.                 Log.d("DEBUG", "addddddddddddddddddding this here");
  23.  
  24.                 super.onCallStateChanged(state, incomingNumber);
  25.  
  26.                 Log.d("DEBUG", TelephonyManager.CALL_STATE_OFFHOOK + "
  27.  
  28. weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee are def in
  29.  
  30. here: " + state);
  31.  
  32.  
  33.  
  34.                 switch(state)
  35.  
  36.                 {
  37.  
  38.                         case TelephonyManager.CALL_STATE_IDLE:
  39.  
  40.                                 Log.d("DEBUG", "phhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhone is idle");
  41.  
  42.                                 break;
  43.  
  44.                         case TelephonyManager.CALL_STATE_OFFHOOK:
  45.  
  46.                                 Log.d("DEBUG", "phoooooooooooooooooooooooooooooooooooooon is off
  47.  
  48. hook");
  49.  
  50.                                 break;
  51.  
  52.                         case TelephonyManager.CALL_STATE_RINGING:
  53.  
  54.                                 Log.d("DEBUG",
  55.  
  56. "phoooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnnneeeeeeeeeeeeeeeeee
  57.  
  58. is ringing");
  59.  
  60.                                 break;
  61.  
  62.                         default:
  63.  
  64.                                 Log.d("DEBUG", "The staaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaate is " +
  65.  
  66. state);
  67.  
  68.  
  69.  
  70.                 }
  71.  
  72.         }
  73.  
  74.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4



and my manifest file i have:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <receiver android:name=".StartServicesAtStartUp">
  3.  
  4.                 <intent-filter>
  5.  
  6.                         <action android:name="android.intent.action.BOOT_COMPLETED" />
  7.  
  8.                         <category android:name="android.intent.category.HOME" />
  9.  
  10.                 </intent-filter>
  11.  
  12.         </receiver>
  13.  
  14.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
chouman
Developer
Developer
 
Posts: 27
Joined: Thu Jan 03, 2008 2:59 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 25 guests