B
bhagavathram
Guest
Hi all ,
When i try to detect incoming calls with phonestatelistener, it excites multiple times. This is my code. onCallStateChanged method is called multiple times.
1. onCallStateChanged o Service
2 .public int onStartCommand(Intent intent, int flags, int startId)
{
callHelper = new CallHelper(this);
callHelperl.start
}
-------------
callHelper.java
public void start()
{
TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
private class CallStateListener extends PhoneStateListener
{
Context context;
public void PhoneStateListener(Context context)
{
this.context = context;
}
@Override
public void onCallStateChanged(int state, final String incomingNumber)
{
System.out.println("onCallStateChanged Method" +state );
String ip = null;
switch (state)
{
case TelephonyManager.CALL_STATE_RINGING:
sysout("call ring ")
break;
}
}
}
Thanks in advance.
bhagavath
When i try to detect incoming calls with phonestatelistener, it excites multiple times. This is my code. onCallStateChanged method is called multiple times.
1. onCallStateChanged o Service
2 .public int onStartCommand(Intent intent, int flags, int startId)
{
callHelper = new CallHelper(this);
callHelperl.start
}
-------------
callHelper.java
public void start()
{
TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
private class CallStateListener extends PhoneStateListener
{
Context context;
public void PhoneStateListener(Context context)
{
this.context = context;
}
@Override
public void onCallStateChanged(int state, final String incomingNumber)
{
System.out.println("onCallStateChanged Method" +state );
String ip = null;
switch (state)
{
case TelephonyManager.CALL_STATE_RINGING:
sysout("call ring ")
break;
}
}
}
Thanks in advance.
bhagavath