Hi
I'm not able to see what I'm missing to get CALL_STATE events. Here is
what I have and I believe it used to work for me. Last weekend I lost
my original working application along with other files :(
Please let me know if you spot something in my app:
1. MyService class
public MyService extends Service {
private PhoneStateListener mPhoneEvent = new PhoneStateListener()
{
public void onCallSateChanged(int state, String inNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
Log.d(LOGTAG, "############# Phone State Idle for" +
inNumber);
break;
case TelephonyManager.CALL_STATE_RINGING:
Log.d(LOGTAG, "############### Phone State Ringing for
" + inNumber);
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d(LOGTAG, "########## Phone State Offhook for " +
inNumber);
break;
default:
Log.e(LOGTAG, "########## Invalid Phone State = " +
state);
break;
}
}
};
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(LOGTAG, "onStartCommand");
super.onStartCommand(intent, flags, startId);
mPhoneManager = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
mPhoneManager.listen(mPhoneEvent,
PhoneStateListener.LISTEN_CALL_STATE);
// I see below debug log in adb logcat.
Log.d(LOGTAG, "@@@@@@@@@@@@ Set Phonelistener");
return START_STICKY;
}
public void onDestroy() {
super.onDestroy();
// Do not see this below line in logcat and I believe which is a
good thing for me.
Log.d(LOGTAG, "####### Destroy Is Called.");
}
}
Android XML File:
=================
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".MonitorActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".MyService">
<!-- <intent-filter>
<category
android:name="android.intent.category.DEFAULT" />
</intent-filter>
-->
</service>
</application>
<uses-permission
android:name="android.permission.READ_PHONE_STATE"/>
=====================================
Application Logic: I created an MonitorActivity class which starts
MyService class to monitor CallState events.
Just 4days back downloaded Android SDK and it is Revision11.
Thanks in advance.
-lb
--
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