How to check phone service state in android
<p>I am developing an app in which i am trying to check the service state of phone </p>

<p>using  Service state: IN_SERVICE 
if the phone is IN_SERVICE generate a Toast phone is in service if its not then generate a Toast phone is not in service
 im trying this code </p>

<pre><code>public class MyphoneStateListener extends PhoneStateListener
{
public void onCallStateChanged(int state, String incomingNumber)
{
     switch (state) {  
        case TelephonyManager.CALL_STATE_IDLE:   
            break;  
        case TelephonyManager.CALL_STATE_RINGING: 
           sendemail(); 
            break;  
        case TelephonyManager.CALL_STATE_OFFHOOK:  
        default:  
            break;  
        }  
        super.onCallStateChanged(state, incomingNumber);  
    }
}
</code></pre>

<p>not able to get the  Service state: IN_SERVICE    Please help me 
Thanks in advance </p>
