Program: 161544
Project: 161544
Buggy source:
private void submitAndTabListeners(){
  submitSurveyButton.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      if (!checkSurveyData()) {
        return;
      }
      final ArrayList<String> selectedFacIds=new ArrayList<String>();
      if (!selectedFaculties.isEmpty()) {
        for (int j=0; j < selectedFaculties.size(); j++) {
          for (int x=0; x < fetchedFaculties.size(); x++) {
            if (selectedFaculties.get(j).equals(fetchedFaculties.get(x))) {
              Cursor cursor=surveyManager.getFacultyID(selectedFaculties.get(j));
              if (cursor.moveToFirst()) {
                selectedFacIds.add(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
              }
            }
          }
        }
      }
 else {
        Cursor c=surveyManager.getAllFaculties();
        if (c.moveToFirst()) {
          do {
            selectedFacIds.add(c.getString(c.getColumnIndex("String_Node_Str")));
          }
 while (c.moveToNext());
        }
      }
      if (NetUtils.isConnected(getApplication())) {
        for (int i=0; i < aSpinner1.getSelectedItemPosition() + 1; i++) {
          Question ques=new Question(questions.get(i),selectedFacIds);
          try {
            TUMCabeClient.getInstance(getApplicationContext()).createQuestion(ques,new Callback<Question>(){
              @Override public void success(              Question question,              Response response){
                Utils.log("String_Node_Str" + response.getBody().toString());
                numberOfQuestion++;
                Toast.makeText(getApplicationContext(),getResources().getString(R.string.survey_submitted),Toast.LENGTH_SHORT).show();
              }
              @Override public void failure(              RetrofitError error){
                Utils.log("String_Node_Str" + error.toString());
              }
            }
);
          }
 catch (          Exception e) {
            Utils.log(e.toString());
          }
        }
        clearData();
        new AsyncTask<Void,Void,Void>(){
          @Override protected Void doInBackground(          Void... voids){
            surveyManager.downLoadOwnQuestions();
            return null;
          }
          @Override protected void onPostExecute(          Void v){
            restartActivity();
          }
        }
.execute();
      }
 else       Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_LONG).show();
    }
  }
);
  tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener(){
    @Override public void onTabChanged(    String s){
      int currentTab=tabHost.getCurrentTab();
      Utils.log("String_Node_Str" + currentTab);
      if (currentTab == 0) {
        mainResponseLayout.removeAllViews();
      }
 else {
        if (NetUtils.isConnected(getApplication())) {
          new AsyncTask<Void,Void,Void>(){
            @Override protected Void doInBackground(            Void... voids){
              surveyManager.downLoadOwnQuestions();
              return null;
            }
            @Override protected void onPostExecute(            Void v){
              setUpResponseTab();
            }
          }
.execute();
        }
 else {
          setUpResponseTab();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
private void submitAndTabListeners(){
  submitSurveyButton.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      if (!checkSurveyData()) {
        return;
      }
      final ArrayList<String> selectedFacIds=new ArrayList<String>();
      if (!selectedFaculties.isEmpty()) {
        for (int j=0; j < selectedFaculties.size(); j++) {
          for (int x=0; x < fetchedFaculties.size(); x++) {
            if (selectedFaculties.get(j).equals(fetchedFaculties.get(x))) {
              Cursor cursor=surveyManager.getFacultyID(selectedFaculties.get(j));
              if (cursor.moveToFirst()) {
                selectedFacIds.add(cursor.getString(cursor.getColumnIndex("String_Node_Str")));
              }
            }
          }
        }
      }
 else {
        Cursor c=surveyManager.getAllFaculties();
        if (c.moveToFirst()) {
          do {
            selectedFacIds.add(c.getString(c.getColumnIndex("String_Node_Str")));
          }
 while (c.moveToNext());
        }
      }
      if (NetUtils.isConnected(getApplication())) {
        for (int i=0; i < aSpinner1.getSelectedItemPosition() + 1; i++) {
          Question ques=new Question(questions.get(i),selectedFacIds);
          try {
            TUMCabeClient.getInstance(getApplicationContext()).createQuestion(ques,new Callback<Question>(){
              @Override public void success(              Question question,              Response response){
                Utils.log("String_Node_Str" + response.getBody().toString());
                numberOfQuestion++;
                Toast.makeText(getApplicationContext(),getResources().getString(R.string.survey_submitted),Toast.LENGTH_SHORT).show();
              }
              @Override public void failure(              RetrofitError error){
                Utils.log("String_Node_Str" + error.toString());
              }
            }
);
          }
 catch (          Exception e) {
            Utils.log(e.toString());
          }
        }
        clearData();
        new AsyncTask<Void,Void,Void>(){
          @Override protected Void doInBackground(          Void... voids){
            surveyManager.downLoadOwnQuestions();
            return null;
          }
          @Override protected void onPostExecute(          Void v){
            restartActivity();
          }
        }
.execute();
      }
 else       restartActivity();
    }
  }
);
  tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener(){
    @Override public void onTabChanged(    String s){
      int currentTab=tabHost.getCurrentTab();
      Utils.log("String_Node_Str" + currentTab);
      if (currentTab == 0) {
        mainResponseLayout.removeAllViews();
      }
 else {
        if (NetUtils.isConnected(getApplication())) {
          new AsyncTask<Void,Void,Void>(){
            @Override protected Void doInBackground(            Void... voids){
              surveyManager.downLoadOwnQuestions();
              return null;
            }
            @Override protected void onPostExecute(            Void v){
              setUpResponseTab();
            }
          }
.execute();
        }
 else {
          setUpResponseTab();
        }
      }
    }
  }
);
}