[Solved] Why can’t able to use if/else in AsyncTask? [closed]


The if is not in any method. It’s just lose at the class level. Put it inside the do in background or better yet its own method:

private String getUrl(Double lat, Double long) {
   if(lat != null && lng!= null) {
      String URL = "http://xyz.in/api/stores/around_me.json?app_id=test&lat="
                + lat + "&lng=" + lng;
      return URL;
   }
   else {
      String URL = "http://xyz.in/api/stores/around_me.json?       
                           app_id=test&lat=12.58&lng=77.38";
      return URL;
   }
}

As the other answers point out the if condition also has a problem. That should become clearer once it’s in a valid place.

2

solved Why can’t able to use if/else in AsyncTask? [closed]