public class BabyName extends Activity implements View.OnClickListener, Runnable{
/** Called when the activity is first created. */
Login loginclass=new Login();
ProgressDialog dialog;
Thread t=new Thread(this, "sample");
AlertDialog al;
long id;
boolean flg=false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button launch=(Button)findViewById(R.id.login_button);
launch.setOnClickListener(this);
}
public void onClick(View viewparam){
EditText username=(EditText)findViewById(R.id.txt_username);
EditText password=(EditText)findViewById(R.id.txt_password);
String sUserName = username.getText().toString();
String sPassword = password.getText().toString();
dialog=ProgressDialog.show(BabyName.this, "", "Please wait for few seconds...", true);
loginclass.setId(sUserName);
loginclass.setPassword(sPassword);
al=new AlertDialog.Builder(this).create();
id=t.getId();
t.start();
message();
}
public void run(){
Get_Data getdata=new Get_Data();
getdata.logincheck(loginclass);
dialog.dismiss();
}
public void message(){
if(loginclass.getStatus().trim().equals("true")){
dialog.dismiss();
/* Intent i = new Intent(BabyNames.this, ChoiceActivity.class);
startActivityForResult(i, SUB_ACTIVITY_REQUEST_CODE);*/
}else if(loginclass.getStatus().trim().equals("false")){
al.setTitle("Error");
al.setMessage("Username or password incorrect!!");
al.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
} });
al.show();
}else {
//al=new AlertDialog.Builder(this).create();
al.setTitle("Http Error");
al.setMessage("Not Connected");
al.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
} });
al.show();
}
}
}
This is the code of login page of android and when i enter click login button the progressdialog appears and after that alertbox must be shown if username or password incorrect but it is not showing that alert.
so is there any problem in threading or something else? please help me