In my android project I am trying to call a web service which returns a string result. After execution, result will updated in UI thread using onPostExecution() and the result will decide whether to move to next activity or to notify user to correct information.
Above is my intention to achieve from below code :
BackgroundTask bcktask = new BackgroundTask();
bcktask.execute(servicemethodname, urlparameter, bMap);
Thread.sleep(1000);
//do nothing
while (backgroundResult == null)
;
if (backgroundResult == "Sucessfully Registered") {
Intent intent = new Intent(this, VerifyDetail.class);
startActivity(intent);
} else {
Toast.makeText(this, backgroundResult, Toast.LENGTH_LONG)
.show();
}
but problem is that when I try to run above code It stucks at UI thread and background thread is not running or perhaps not getting CPU time to execute. Please tell me how can I get this done. I need to hold the activity and show a message (what is wrong) if result is not Sucessfully Registered or screen will change to next activity.
Thanks & Regards,
Sourabh