Stop tts if the call is in offHook
<p>I am doing an application which speaks the caller name after 4 sec of the ring tone.The problem is it speaks the caller Name after two or three rings. The problem is it keeps speaking the caller name even if the call is in offhook or idle I don't want so.</p>

<p>the code in onreceive of broadcast receiver is</p>

<pre><code>  state = bundle.getString(TelephonyManager.EXTRA_STATE);
         if(state.equals( TelephonyManager.CALL_STATE_OFFHOOK))   
         {
            System.out.println("fjkerj"); 
         }
         else if(state.equals( TelephonyManager.CALL_STATE_IDLE))   
         {

         }

         else if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
         {
             System.out.println("Entered Receiver");
                 final String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);   
   //                     String info = "Detect Calls sample application\nIncoming number: " + phonenumber;
                 AudioManager amanager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
             switch (amanager.getRingerMode()) {
             case AudioManager.RINGER_MODE_SILENT:
             System.out.println("Silent");
                 break;
             case AudioManager.RINGER_MODE_VIBRATE:
                 System.out.println("Vibrate");
                 break;
             case AudioManager.RINGER_MODE_NORMAL:

                 amanager.setStreamVolume(AudioManager.STREAM_RING,1, 0);    
                 Handler handler=new Handler();
                  Runnable r=new Runnable()
                  {
                      public void run() 
                      {

                          if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
                          {
                              Intent IncomingNumberIntent = new Intent(context1,SpeakOut.class);  
                              IncomingNumberIntent.putExtra("PhoneNumber", phonenumber);
                              context1.startService(IncomingNumberIntent); 
                          }

                      }
                  };
                  handler.postDelayed(r, 3000);       
</code></pre>

<p>If the call is in ringing and profile is normal, it will go to a service and talks the name but
the trouble that app speaks the name even if the call is offhook.</p>
