title: Why can't able to use if/else in AsyncTask?
body: <p>Why I can't able to use if/else block in <strong>AsyncTast</strong>.</p>
  
  <p>When I try using if/else its throwing me "<strong>Syntax Error</strong>".</p>
  
  <p>This is my code junk. </p>
  
  <pre><code>    package com.xyz.asd;
  
      @SuppressLint("NewApi")
      public class MapActivity extends Activity implements LocationListener {
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_map);
              locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
      // taking location by GPS / network 
              if(location!=null)
              {
      // move camear to latlong by locationManager 
      new HttpGetTask().execute();
              }
              else
              {
                  // pass hard coded lat long to move camera
                  new HttpGetTask().execute();
              }
  
              if (location != null) {
      //Display some toast
              }
          }
          @Override
          protected void onPause() {
      // bla bla
          }
          @Override
          protected void onResume() {
      // bla bla
          }
          @Override
          public boolean onCreateOptionsMenu(Menu menu) {
      // bla bla
          }
          @Override
          public void onLocationChanged(Location location) {
              // TODO Auto-generated method stub
          }
          public boolean onOptionsItemSelected(MenuItem item) {
      // bla bla             
              }
          }
          @Override
          public void onProviderDisabled(String provider) {
              // TODO Auto-generated method stub
      //bla 
          }
          @Override
          public void onProviderEnabled(String provider) {
              // TODO Auto-generated method stub
      //bla
          }
          @Override
          public void onStatusChanged(String provider, int status, Bundle extras) {
              // TODO Auto-generated method stub
          }
  
  
          private class HttpGetTask extends AsyncTask&lt;Void, Void, String&gt; {
              protected void onPreExecute() {
                  super.onPreExecute();
                  // Showing progress dialog
              }
              Double lat = locationManager.getLastKnownLocation(provider)
                      .getLatitude();
              Double lng = locationManager.getLastKnownLocation(provider)
                      .getLongitude();
  
  **//*************************PROBLEM IN IF ELSE***********************************
              if(lat != null &amp;&amp; lng!= null)
              {String URL = "http://xyz.in/api/stores/around_me.json?app_id=test&amp;lat="
                      + lat + "&amp;lng=" + lng; }
              else
              {
              String URL = "http://xyz.in/api/stores/around_me.json?       
                                 app_id=test&amp;lat=12.58&amp;lng=77.38";
              }
  //********************************************************************************
  
              AndroidHttpClient mClient = AndroidHttpClient.newInstance("");
              @Override
              protected String doInBackground(Void... params) {
  
  
                  HttpGet request = new HttpGet(URL);
  
                  ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();
                  try {
                      return mClient.execute(request, responseHandler);
                  } catch (ClientProtocolException exception) {
                      exception.printStackTrace();
                  } catch (IOException exception) {
                      exception.printStackTrace();
                  }
                  return null;
              }
              @Override
              protected void onPostExecute(String result) {
                  if (pDialog.isShowing())
                      pDialog.dismiss();
                  try {
  
      //JSON parsing 
                      }
                  });
                  if (null != mClient)
                      mClient.close();
              }
          }
      }
  </code></pre>
  
  <p>Can anybody suggest me what/why it is showing this behavior?
  Am I wrong?  How can I correct my condition to pass valid URL to my http get request?</p>