alert dialog in function(java coding) for android
<p>i have a function here that checks the user information...</p>

<pre><code>//check age, height, weight, RHR
public void infocheck(int age, int height, int weight, int RHR){
    int invalid = 0;
    if(age&lt;5||age&gt;99)//5 to 99 years old = valid
    {
        new AlertDialog.Builder(cont)
        .setMessage("Age should be 5 to 99 years old")
        .setNeutralButton("OK", null).show();
        invalid++;
    }
    if(height&lt;36||height&gt;=96)//3 to 8 feet =  valid
    {
        new AlertDialog.Builder(cont)
        .setMessage("Height should be from 36 to 96 inches tall")
        .setNeutralButton("OK", null).show();
        invalid++;
    }
    if(weight&lt;50||weight&gt;=500)
    {
        new AlertDialog.Builder(cont)
        .setMessage("Weight should range from 50 to 500 pounds")
        .setNeutralButton("OK", null).show();
        invalid++;
    }
    if(RHR&lt;30||RHR&gt;=100)
    {
        new AlertDialog.Builder(cont)
        .setMessage("Resting Heart Rate should be at 30 to 100 beats per minute")
        .setNeutralButton("OK", null).show();
        invalid++;
    }
    if(invalid&gt;0)
    {
        return;
    }

}
</code></pre>

<p>and in my onClick in my activity is here(which saves information when click) is this...</p>

<pre><code>                if(!isAlpha(name))
            {
                new AlertDialog.Builder(cont)
                .setMessage("Please input a valid name")
                .setNeutralButton("OK", null).show();
            }
            else 
            {
                infocheck(age, weight,height,RHR);
                //if all info are valid proceed "Are you sure?"
                new AlertDialog.Builder(cont)
                .setMessage("Are you sure?")
                .setPositiveButton("YES", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        //TODO
                        intent= new Intent(cont,MainActivity.class);
                        startActivity(intent);
                    }
                }).setNegativeButton("NO",null).show();
            }
</code></pre>

<p>my problem is that when the user clicks, and proceed to infocheck(); and there is invalid, "Are you sure?" alert dialog still appears</p>
