Program: 50889
Project: 50889
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.stopchooser);
  db=((BusFollowerApplication)getApplication()).getDatabase();
  stopSearchField=(AutoCompleteTextView)findViewById(R.id.stopSearch);
  final Button chooseMapButton=(Button)findViewById(R.id.chooseMap);
  if (savedInstanceState != null) {
    if (fetchRoutesTask != null) {
      fetchRoutesTask.setActivityContext(this);
    }
    if (fetchTripsTask != null) {
      fetchTripsTask.setActivityContext(this);
    }
  }
  SimpleCursorAdapter adapter;
  if (android.os.Build.VERSION.SDK_INT < 11) {
    adapter=new SimpleCursorAdapter(this,android.R.layout.simple_dropdown_item_1line,null,new String[]{"String_Node_Str"},new int[]{android.R.id.text1});
  }
 else {
    adapter=new SimpleCursorAdapter(this,android.R.layout.simple_dropdown_item_1line,null,new String[]{"String_Node_Str"},new int[]{android.R.id.text1},0);
  }
  stopSearchField.setAdapter(adapter);
  adapter.setCursorToStringConverter(new CursorToStringConverter(){
    @Override public String convertToString(    Cursor cursor){
      return cursor.getString(cursor.getColumnIndexOrThrow("String_Node_Str"));
    }
  }
);
  adapter.setFilterQueryProvider(new FilterQueryProvider(){
    @Override public Cursor runQuery(    CharSequence constraint){
      Log.d(TAG,"String_Node_Str");
      if (constraint == null) {
        return null;
      }
      String constraintStr=constraint.toString();
      String[] pieces=constraintStr.split("String_Node_Str");
      String query="String_Node_Str";
      ArrayList<String> params=new ArrayList<>();
      boolean validQuery=false;
      for (      String piece : pieces) {
        if (piece.length() > 0) {
          validQuery=true;
          query+="String_Node_Str";
          params.add("String_Node_Str" + piece + "String_Node_Str");
          if (piece.matches("String_Node_Str")) {
            query+="String_Node_Str";
            params.add(piece + "String_Node_Str");
          }
          query+="String_Node_Str";
        }
      }
      if (!validQuery) {
        return null;
      }
      query+="String_Node_Str";
      Cursor cursor=db.rawQuery(query,params.toArray(new String[params.size()]));
      if (cursor != null) {
        cursor.moveToFirst();
        Log.d(TAG,"String_Node_Str");
        return cursor;
      }
      Log.d(TAG,"String_Node_Str");
      return null;
    }
  }
);
  stopSearchField.setOnEditorActionListener(new OnEditorActionListener(){
    @Override public boolean onEditorAction(    TextView v,    int actionId,    KeyEvent event){
      if (actionId == EditorInfo.IME_ACTION_GO || (actionId == EditorInfo.IME_NULL && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) {
        fetchRoutesTask=new FetchRoutesTask(StopChooserActivity.this,db);
        fetchRoutesTask.execute(stopSearchField.getText().toString());
        return true;
      }
      return false;
    }
  }
);
  stopSearchField.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      fetchRoutesTask=new FetchRoutesTask(StopChooserActivity.this,db);
      fetchRoutesTask.execute(stopSearchField.getText().toString());
    }
  }
);
  chooseMapButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(StopChooserActivity.this,MapChooserActivity.class);
      startActivity(intent);
    }
  }
);
  ListView recentList=(ListView)findViewById(R.id.recentList);
  recentQueryAdapter=new RecentQueryAdapter(this,android.R.layout.simple_list_item_1,new ArrayList<RecentQuery>());
  recentList.setAdapter(recentQueryAdapter);
  recentList.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View v,    int position,    long id){
      RecentQuery query=recentQueryAdapter.getItem(position);
      if (query.getRoute() == null) {
        fetchRoutesTask=new FetchRoutesTask(StopChooserActivity.this,db);
        fetchRoutesTask.execute(query.getStop().getNumber());
      }
 else {
        fetchTripsTask=new FetchTripsTask(StopChooserActivity.this,db);
        fetchTripsTask.execute(query);
      }
    }
  }
);
  checkPlayServices();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.stopchooser);
  db=((BusFollowerApplication)getApplication()).getDatabase();
  stopSearchField=(AutoCompleteTextView)findViewById(R.id.stopSearch);
  final Button chooseMapButton=(Button)findViewById(R.id.chooseMap);
  if (savedInstanceState != null) {
    if (fetchRoutesTask != null) {
      fetchRoutesTask.setActivityContext(this);
    }
    if (fetchTripsTask != null) {
      fetchTripsTask.setActivityContext(this);
    }
  }
  SimpleCursorAdapter adapter;
  if (android.os.Build.VERSION.SDK_INT < 11) {
    adapter=new SimpleCursorAdapter(this,android.R.layout.simple_dropdown_item_1line,null,new String[]{"String_Node_Str"},new int[]{android.R.id.text1});
  }
 else {
    adapter=new SimpleCursorAdapter(this,android.R.layout.simple_spinner_dropdown_item,null,new String[]{"String_Node_Str"},new int[]{android.R.id.text1},0);
  }
  stopSearchField.setAdapter(adapter);
  adapter.setCursorToStringConverter(new CursorToStringConverter(){
    @Override public String convertToString(    Cursor cursor){
      return cursor.getString(cursor.getColumnIndexOrThrow("String_Node_Str"));
    }
  }
);
  adapter.setFilterQueryProvider(new FilterQueryProvider(){
    @Override public Cursor runQuery(    CharSequence constraint){
      Log.d(TAG,"String_Node_Str");
      if (constraint == null) {
        return null;
      }
      String constraintStr=constraint.toString();
      String[] pieces=constraintStr.split("String_Node_Str");
      String query="String_Node_Str";
      ArrayList<String> params=new ArrayList<>();
      boolean validQuery=false;
      for (      String piece : pieces) {
        if (piece.length() > 0) {
          validQuery=true;
          query+="String_Node_Str";
          params.add("String_Node_Str" + piece + "String_Node_Str");
          if (piece.matches("String_Node_Str")) {
            query+="String_Node_Str";
            params.add(piece + "String_Node_Str");
          }
          query+="String_Node_Str";
        }
      }
      if (!validQuery) {
        return null;
      }
      query+="String_Node_Str";
      Cursor cursor=db.rawQuery(query,params.toArray(new String[params.size()]));
      if (cursor != null) {
        cursor.moveToFirst();
        Log.d(TAG,"String_Node_Str");
        return cursor;
      }
      Log.d(TAG,"String_Node_Str");
      return null;
    }
  }
);
  stopSearchField.setOnEditorActionListener(new OnEditorActionListener(){
    @Override public boolean onEditorAction(    TextView v,    int actionId,    KeyEvent event){
      if (actionId == EditorInfo.IME_ACTION_GO || (actionId == EditorInfo.IME_NULL && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) {
        fetchRoutesTask=new FetchRoutesTask(StopChooserActivity.this,db);
        fetchRoutesTask.execute(stopSearchField.getText().toString());
        return true;
      }
      return false;
    }
  }
);
  stopSearchField.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      fetchRoutesTask=new FetchRoutesTask(StopChooserActivity.this,db);
      fetchRoutesTask.execute(stopSearchField.getText().toString());
    }
  }
);
  chooseMapButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(StopChooserActivity.this,MapChooserActivity.class);
      startActivity(intent);
    }
  }
);
  ListView recentList=(ListView)findViewById(R.id.recentList);
  recentQueryAdapter=new RecentQueryAdapter(this,android.R.layout.simple_list_item_1,new ArrayList<RecentQuery>());
  recentList.setAdapter(recentQueryAdapter);
  recentList.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View v,    int position,    long id){
      RecentQuery query=recentQueryAdapter.getItem(position);
      if (query.getRoute() == null) {
        fetchRoutesTask=new FetchRoutesTask(StopChooserActivity.this,db);
        fetchRoutesTask.execute(query.getStop().getNumber());
      }
 else {
        fetchTripsTask=new FetchTripsTask(StopChooserActivity.this,db);
        fetchTripsTask.execute(query);
      }
    }
  }
);
  checkPlayServices();
}