Hi,

Did you describe your StartServicesAtStartUp in your
AndroidManifest.xml, for example:

        <receiver android:name=".StartServicesAtStartUp">
            <intent-filter>
                <action
android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

And you should request user-permission
"android.permission.RECEIVE_BOOT_COMPLETED" like
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
in the AndroidManifest.xml.

Cheers,
Nayr

On Sep 27, 9:01 am, chouman82 <[EMAIL PROTECTED]> wrote:
> 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!!!
>
> Here is my code:
>
> import android.content.BroadcastReceiver;
> import android.content.Context;
> import android.content.Intent;
> import android.telephony.PhoneStateListener;
> import android.telephony.TelephonyManager;
> import android.util.Log;
>
> import com.lumitrend.netlogger.Logger;
>
> public class StartServicesAtStartUp extends BroadcastReceiver
> {
>         public void onReceive(Context context, Intent intent)
>         {
>                 Log.d("DEBUG",
> "########################################################################") ;
>                 //Intent phoneStateListener = new Intent(context,
> CallStateListener.class);
>                 //phoneStateListener.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
>                 //context.startService(phoneStateListener);
>                 Log.d("DEBUG", context.getPackageName());
>                 Log.d("DEBUG", context.toString());
>                 TelephonyManager tManager =
> (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
>                 CallStateListener callStateListener = new CallStateListener();
>                 tManager.listen(callStateListener,
> PhoneStateListener.LISTEN_CALL_STATE);
>         }
>
> }
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> import android.telephony.PhoneStateListener;
> import android.telephony.TelephonyManager;
> import android.util.Log;
>
> import com.lumitrend.netlogger.Logger;
>
> public class CallStateListener extends PhoneStateListener
> {
>         public void onCallStateChanged(int state, String incomingNumber)
>         {
>                 Log.d("DEBUG", "addddddddddddddddddding this here");
>                 super.onCallStateChanged(state, incomingNumber);
>                 Log.d("DEBUG", TelephonyManager.CALL_STATE_OFFHOOK + "
> weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee are def in
> here: " + state);
>
>                 switch(state)
>                 {
>                         case TelephonyManager.CALL_STATE_IDLE:
>                                 Log.d("DEBUG", 
> "phhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhone is idle");
>                                 break;
>                         case TelephonyManager.CALL_STATE_OFFHOOK:
>                                 Log.d("DEBUG", 
> "phoooooooooooooooooooooooooooooooooooooon is off
> hook");
>                                 break;
>                         case TelephonyManager.CALL_STATE_RINGING:
>                                 Log.d("DEBUG",
> "phoooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnnneeeeeeeeeeeeeeeeee
> is ringing");
>                                 break;
>                         default:
>                                 Log.d("DEBUG", "The 
> staaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaate is " +
> state);
>
>                 }
>         }
>
> }

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to