i have this code and in MyAsyncOpenUrl i get a jason and parse it to read server message . i store it in a public variable name message. but my problem is the if statement is running before the server message arrives. how can i wait the task until i get the message ? by what i read in this question it seems i can use get method , but i dont know how to use it ?!!! :(
message = "";
MyAsyncOpenUrl task1 = new MyAsyncOpenUrl("http://test.com/op.php");
try {
task1.execute(myURL).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
//task1.onPostExecute(null);
if (message.equals("fail"))
Toast.makeText(getBaseContext(), "Operation faild!", Toast.LENGTH_LONG).show();