Async Task returning int value after network working
I have my Asyntask structure as:

    private class GetMyFlights extends AsyncTask<String, Void, Integer> {		
		private ProgressDialog dialog;	
		
		public GetMyFlights(ListActivity activity) {}
		 	
		protected void onPreExecute() {
			if(mFirstOpen){
				mFirstOpen = false;
				dialog = new ProgressDialog(mCtx);
				this.dialog.setMessage(getResources().getString(R.string.common_getting_data));
				this.dialog.show();
			}
        	}		
	
		@Override
		protected Integer doInBackground(String... params) {
			return getData();
		}		

		@Override
		protected void onPostExecute(Integer result) {	
			super.onPostExecute(result);	
			//if(mFinishGettingData){  //global variable 
				mFinishGettingData = false;
				switch(result){
					case 0:
						//...					
					break;
					case 1:
						//...
					break;
					case 2:				
						//...
					break;
								
				}
			//}			
		}
	}

And my method getData:

    private int getData() {		
		try{
			myFlightsA = new FlightAdapter(this, R.layout.row_myflight, WithingsAPI.getInstance().getFutureFlights());
			//mFinishGettingData = true;
			if(myFlightsA != null)
				return 0;
		}catch(NetworkConnetionException e){
			if(e.getMessage().equals(NetworkConnetionException.ERROR_CONNECTION))
				return 1;
			else if(e.getMessage().equals(NetworkConnetionException.NOT_LOGGED)){
				Log.d(TAG, "Not Logged");
				return 2;
			}
		}catch(Exception e){
			Log.d(TAG, e.toString());
		}		
		return 3;
	}

But I dont know if I am doing something wrong, as sometimes the Task work as expected but sometimes appears the dialog as getData returns 3 and afterwards 1.

I have thought about using a global variable `mFinishGettingData` to notify the ending of the network working.


Async Task returning int value after network working
===

I have my Asyntask structure as:

    private class GetMyFlights extends AsyncTask<String, Void, Integer> {		
		private ProgressDialog dialog;	
		
		public GetMyFlights(ListActivity activity) {}
		 	
		protected void onPreExecute() {
			if(mFirstOpen){
				mFirstOpen = false;
				dialog = new ProgressDialog(mCtx);
				this.dialog.setMessage(getResources().getString(R.string.common_getting_data));
				this.dialog.show();
			}
        	}		
	
		@Override
		protected Integer doInBackground(String... params) {
			return getData();
		}		

		@Override
		protected void onPostExecute(Integer result) {	
			super.onPostExecute(result);	
			//if(mFinishGettingData){  //global variable 
				mFinishGettingData = false;
				switch(result){
					case 0:
						//...					
					break;
					case 1:
						//...
					break;
					case 2:				
						//...
					break;
								
				}
			//}			
		}
	}

And my method getData:

    private int getData() {		
		try{
			myFlightsA = new FlightAdapter(this, R.layout.row_myflight, WithingsAPI.getInstance().getFutureFlights());
			//mFinishGettingData = true;
			if(myFlightsA != null)
				return 0;
		}catch(NetworkConnetionException e){
			if(e.getMessage().equals(NetworkConnetionException.ERROR_CONNECTION))
				return 1;
			else if(e.getMessage().equals(NetworkConnetionException.NOT_LOGGED)){
				Log.d(TAG, "Not Logged");
				return 2;
			}
		}catch(Exception e){
			Log.d(TAG, e.toString());
		}		
		return 3;
	}

But I dont know if I am doing something wrong, as sometimes the Task work as expected but sometimes appears the dialog as getData returns 3 and afterwards 1.

I have thought about using a global variable `mFinishGettingData` to notify the ending of the network working.

