Android - PhoneStateListener behaving oddly?
<p>Inside this code I write two Log.w statements to see when the app realized a call just came in or not.  But every time the code runs and I do a mock phone call, both log.w statements print together.  So this means both the if AND else are entered? Why is this happening?</p>

<pre><code>package nick.mccollum.importantcall;

import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;

public class PhoneCallListener extends PhoneStateListener{
    @Override
    public void onCallStateChanged(int state, String number){
        if(TelephonyManager.CALL_STATE_RINGING == state){
            ImportantCallActivity.setWasRinging(true);
            Log.w("phone call", "RINGING");
        }
        if(TelephonyManager.CALL_STATE_IDLE == state){
            //call log lookup
            if(ImportantCallActivity.getWasRinging() == true){
            Log.w("phone call", "over wasRinging = " + String.valueOf(ImportantCallActivity.getWasRinging()));
            //ImportantCallActivity.lookup();
            }
            else{
                ImportantCallActivity.setWasRinging(false);
                Log.w("phone call", "phone was not ringing wasRing =" + String.valueOf(ImportantCallActivity.getWasRinging()));
            }
            ImportantCallActivity.setWasRinging(false);
    }

}
}
</code></pre>
