Program: 142235
Project: 142235
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.createDataSetObserver();
  EntitySelectActivity oldActivity=(EntitySelectActivity)this.getDestroyedActivityState();
  if (savedInstanceState != null) {
    mResultIsMap=savedInstanceState.getBoolean(EXTRA_IS_MAP,false);
  }
  try {
    asw=CommCareApplication._().getCurrentSessionWrapper();
    session=asw.getSession();
  }
 catch (  SessionUnavailableException sue) {
    this.setResult(Activity.RESULT_CANCELED);
    this.finish();
    return;
  }
  selectDatum=session.getNeededDatum();
  shortSelect=session.getDetail(selectDatum.getShortDetail());
  mNoDetailMode=selectDatum.getLongDetail() == null;
  if (this.getString(R.string.panes).equals("String_Node_Str") && !mNoDetailMode) {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      setContentView(R.layout.screen_compound_select);
      View.inflate(this,R.layout.entity_select_layout,(ViewGroup)findViewById(R.id.screen_compound_select_left_pane));
      inAwesomeMode=true;
      rightFrame=(FrameLayout)findViewById(R.id.screen_compound_select_right_pane);
      TextView message=(TextView)findViewById(R.id.screen_compound_select_prompt);
      message.setText(localize("String_Node_Str",new String[]{Localization.get("String_Node_Str")}));
    }
 else {
      setContentView(R.layout.entity_select_layout);
      if (oldActivity != null) {
        Intent intent=this.getIntent();
        TreeReference selectedRef=SerializationUtil.deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
        if (selectedRef != null) {
          Intent detailIntent=getDetailIntent(selectedRef,null);
          startOther=true;
          startActivityForResult(detailIntent,CONFIRM_SELECT);
        }
 else         if (oldActivity.selectedIntent != null) {
          startActivityForResult(oldActivity.selectedIntent,CONFIRM_SELECT);
          startOther=true;
        }
      }
    }
  }
 else {
    setContentView(R.layout.entity_select_layout);
  }
  ((ListView)this.findViewById(R.id.screen_entity_select_list)).setOnItemClickListener(this);
  TextView searchLabel=(TextView)findViewById(R.id.screen_entity_select_search_label);
  searchLabel.setText(Localization.get("String_Node_Str"));
  searchLabel.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      searchbox.performClick();
      InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      inputMethodManager.showSoftInput(searchbox,InputMethodManager.SHOW_IMPLICIT);
    }
  }
);
  searchbox=(EditText)findViewById(R.id.searchbox);
  searchbox.setMaxLines(3);
  searchbox.setHorizontallyScrolling(false);
  searchResultStatus=(TextView)findViewById(R.id.no_search_results);
  header=(LinearLayout)findViewById(R.id.entity_select_header);
  barcodeButton=(ImageButton)findViewById(R.id.barcodeButton);
  Vector<Entry> entries=session.getEntriesForCommand(session.getCommand());
  prototype=entries.elementAt(0);
  if (entries.size() == 1 && (prototype.getXFormNamespace() == null || prototype.getXFormNamespace().equals("String_Node_Str"))) {
    mViewMode=true;
  }
  barcodeButton.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      Intent i=new Intent("String_Node_Str");
      try {
        startActivityForResult(i,BARCODE_FETCH);
      }
 catch (      ActivityNotFoundException anfe) {
        Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str",Toast.LENGTH_LONG);
        noReader.show();
      }
    }
  }
);
  searchbox.addTextChangedListener(this);
  searchbox.requestFocus();
  if (oldActivity != null) {
    adapter=oldActivity.adapter;
    if (adapter != null) {
      adapter.setController(this);
      ((ListView)this.findViewById(R.id.screen_entity_select_list)).setAdapter(adapter);
      findViewById(R.id.entity_select_loading).setVisibility(View.GONE);
      adapter.unregisterDataSetObserver(oldActivity.mListStateObserver);
      adapter.registerDataSetObserver(this.mListStateObserver);
    }
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.createDataSetObserver();
  EntitySelectActivity oldActivity=(EntitySelectActivity)this.getDestroyedActivityState();
  if (savedInstanceState != null) {
    mResultIsMap=savedInstanceState.getBoolean(EXTRA_IS_MAP,false);
  }
  try {
    asw=CommCareApplication._().getCurrentSessionWrapper();
    session=asw.getSession();
  }
 catch (  SessionUnavailableException sue) {
    this.setResult(Activity.RESULT_CANCELED);
    this.finish();
    return;
  }
  selectDatum=session.getNeededDatum();
  shortSelect=session.getDetail(selectDatum.getShortDetail());
  mNoDetailMode=selectDatum.getLongDetail() == null;
  if (this.getString(R.string.panes).equals("String_Node_Str") && !mNoDetailMode) {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      setContentView(R.layout.screen_compound_select);
      View.inflate(this,R.layout.entity_select_layout,(ViewGroup)findViewById(R.id.screen_compound_select_left_pane));
      inAwesomeMode=true;
      rightFrame=(FrameLayout)findViewById(R.id.screen_compound_select_right_pane);
      TextView message=(TextView)findViewById(R.id.screen_compound_select_prompt);
      message.setText(localize("String_Node_Str",new String[]{Localization.get("String_Node_Str")}));
    }
 else {
      setContentView(R.layout.entity_select_layout);
      if (oldActivity != null) {
        Intent intent=this.getIntent();
        TreeReference selectedRef=SerializationUtil.deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
        if (selectedRef != null) {
          intent.removeExtra(EntityDetailActivity.CONTEXT_REFERENCE);
          Intent detailIntent=getDetailIntent(selectedRef,null);
          startOther=true;
          startActivityForResult(detailIntent,CONFIRM_SELECT);
        }
      }
    }
  }
 else {
    setContentView(R.layout.entity_select_layout);
  }
  ((ListView)this.findViewById(R.id.screen_entity_select_list)).setOnItemClickListener(this);
  TextView searchLabel=(TextView)findViewById(R.id.screen_entity_select_search_label);
  searchLabel.setText(Localization.get("String_Node_Str"));
  searchLabel.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      searchbox.performClick();
      InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      inputMethodManager.showSoftInput(searchbox,InputMethodManager.SHOW_IMPLICIT);
    }
  }
);
  searchbox=(EditText)findViewById(R.id.searchbox);
  searchbox.setMaxLines(3);
  searchbox.setHorizontallyScrolling(false);
  searchResultStatus=(TextView)findViewById(R.id.no_search_results);
  header=(LinearLayout)findViewById(R.id.entity_select_header);
  barcodeButton=(ImageButton)findViewById(R.id.barcodeButton);
  Vector<Entry> entries=session.getEntriesForCommand(session.getCommand());
  prototype=entries.elementAt(0);
  if (entries.size() == 1 && (prototype.getXFormNamespace() == null || prototype.getXFormNamespace().equals("String_Node_Str"))) {
    mViewMode=true;
  }
  barcodeButton.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      Intent i=new Intent("String_Node_Str");
      try {
        startActivityForResult(i,BARCODE_FETCH);
      }
 catch (      ActivityNotFoundException anfe) {
        Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str",Toast.LENGTH_LONG);
        noReader.show();
      }
    }
  }
);
  searchbox.addTextChangedListener(this);
  searchbox.requestFocus();
  if (oldActivity != null) {
    adapter=oldActivity.adapter;
    if (adapter != null) {
      adapter.setController(this);
      ((ListView)this.findViewById(R.id.screen_entity_select_list)).setAdapter(adapter);
      findViewById(R.id.entity_select_loading).setVisibility(View.GONE);
      adapter.unregisterDataSetObserver(oldActivity.mListStateObserver);
      adapter.registerDataSetObserver(this.mListStateObserver);
    }
  }
}