Reputation: 1
I have a parser that grabs a value as a string, if it is not equal to the expected value the below function is called. Only the below function does nothing, it gets to the builder.show() and then jumps back into my parser. It does not show the dialog, because if it did it would hit the finish() on the delegate when the Ok button is selected. Any ideas on what may be causing this issue. I do not know if I have some syntax out of order or what the issue is? I appreciate any and all help.
private void errorReturnReader(string val)
{
string message = "";
if (val != "")
{
AlertDialog.Builder builder;
builder = new AlertDialog.Builder (this,3);
builder.SetTitle("Institution Status Error");
builder.SetCancelable(false);
builder.SetPositiveButton("OK", delegate { Finish(); });
switch (val)
{
case "NO_KEY":
message = "The Key passed does not exist.";
break;
case "NO_EMP":
message = "The employee id does not exist in the specified institution.";
break;
case "NO_INST":
message = "The Institution code associated with key does not exist.";
break;
case "NO_BRANCH":
message = "The Branch value passed does not exist.";
break;
case "EMP_EXCL":
message = "Employee is excluded from all branches.";
break;
case "NO_STAT":
message = "No audit records were found for the branch.";
break;
case "NO_RESPONSE":
message = "No status was returned";
break;
case "NO_COMM":
message = "The Cloud has not communicated with the Console within 60 seconds. Can not verify status.";
break;
default:
break;
}
builder.SetMessage(message);
builder.Create ();
builder.Show ();
}
}
Upvotes: 0
Views: 87
Reputation: 14408
For string comparison use .equals()
,i.e.
Change
if (val != "")
to
if (!"".equals(val))
or
if (val.length() != 0)
For more info see How do I compare strings in Java?
And also to show dialog,change
builder.Create ();
builder.Show ();
to
builder.create().show();
For more info see Android Alert Dialog Example
Upvotes: 1