In my code i want to check longitude and latitude value. If values are empty, code will check for 15 seconds. If values are received , while loop will break and will show "You win". If they are still empty, it should show "error in gps" after 15 seconds. The problem is that code is waiting perfectly but Progress Bar is not showing in the screen because screen got stuck during wait time. After 15 seconds screen is free. Please tell me how to resolve this issue. Thanks
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), longitude.getText(), Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(), latitude.getText(), Toast.LENGTH_LONG).show();
pBar = new ProgressDialog(oproprietor.this);
pBar.setCanceledOnTouchOutside(false);
pBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pBar.setMessage("Waiting 15 seconds");
pBar.show();
long t= System.currentTimeMillis();
long end = t+15000;
while(System.currentTimeMillis() < end) {
if(!longitude.getText().equals("") || !latitude.getText().equals("") ){
pBar.dismiss();
break;
}
else continue;
}
if(longitude.getText().equals("") || latitude.getText().equals("")){
pBar.dismiss();
Toast.makeText(oproprietor.this, "Error in gps", Toast.LENGTH_LONG).show();
}
else if(!longitude.getText().equals("") || !latitude.getText().equals("") ){
pBar.dismiss();
Toast.makeText(oproprietor.this, "You win", Toast.LENGTH_LONG).show();
}
}
});