Hi all,
I have streamed audio from url,but when the call or sms comes i need to pause the song and when the call ends again i am gonna resume the song...
How to do this?...
Hi all,
I have streamed audio from url,but when the call or sms comes i need to pause the song and when the call ends again i am gonna resume the song...
How to do this?...
This method works in my app, it's pretty simple. In your onCreate() put this code to listen for phone events and then act appropriately:
          TelephonyManager telephonyManager;
        PhoneStateListener ringListener;
        // Get the telephony manager
        telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        // Create a new PhoneStateListener
        ringListener = new PhoneStateListener() {
          @Override
          public void onCallStateChanged(int state, String incomingNumber) {
            String stateString = "none";
            switch (state) {
            case TelephonyManager.CALL_STATE_IDLE:
              stateString = "Idle";
              break;
            case TelephonyManager.CALL_STATE_OFFHOOK:
              stateString = "Off Hook";
              break;
            case TelephonyManager.CALL_STATE_RINGING:
              stateString = "Ringing";
            Log.i(TAG, "TELEPHONE RINGING!!");                          
              //Do stuff here when phone ringing detected
            break;
            }
           }
        };
        // Register the listener with the telephony manager
        telephonyManager.listen(ringListener, PhoneStateListener.LISTEN_CALL_STATE);
        //End create a new PhoneStateListener