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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---