Hi everyone,
I have written the following code
public class AndroidPhoneDialer extends Activity {
final EditText phoneNumber = (EditText)
findViewById(R.id.phoneNumber);
final Button callButton = (Button)
findViewById(R.id.callButton);
callButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
if
(validatePhoneNumber(phoneNumber.getText().toString())) {
Intent callIntent = new
Intent(Intent.ACTION_CALL,
Uri.parse("tel:"+ phoneNumber.getText()));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(callIntent);
}
else {
//I WANT TO ADD ALERT DIALOG HERE
}
}
});//end callButton
}//end void
public boolean validatePhoneNumber(String number) {
Pattern phoneNumber = Pattern.compile("(\\d-)?(\\d{3}-)?\\d{3}\
\d{4}");
Matcher matcher = phoneNumber.matcher(number);
return matcher.matches();
}
}
My question is, How do I add an alertDialog?
I notice that AlertDialog has a constructor with the first field being
a "Context" and Context has a default constructor "Context()" I have
tried doing
alertDialog aD = new alertDialog(new Context(), ...)
but that failed to work. Any one can help me out?
Thx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---