Program: 86457
Project: 86457
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  DataHandler.getInstance().addObserver(this);
  mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
  if (!mBluetoothAdapter.isEnabled()) {
    new AlertDialog.Builder(this).setTitle(R.string.bluetooth).setMessage(R.string.bluetoothOff).setPositiveButton(android.R.string.yes,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        mBluetoothAdapter.enable();
        try {
          Thread.sleep(2000);
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
        listBT();
      }
    }
).setNegativeButton(android.R.string.no,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        searchBt=false;
      }
    }
).show();
  }
 else {
    listBT();
  }
  t=GoogleAnalytics.getInstance(this).newTracker("String_Node_Str");
  t.setScreenName("String_Node_Str");
  t.send(new HitBuilders.AppViewBuilder().build());
  plot=(XYPlot)findViewById(R.id.dynamicPlot);
  if (plot.getSeriesSet().size() == 0) {
    Number[] series1Numbers={};
    series1=new SimpleXYSeries(Arrays.asList(series1Numbers),SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,"String_Node_Str");
    LineAndPointFormatter series1Format=new LineAndPointFormatter(Color.rgb(0,0,255),Color.rgb(200,200,200),null,null);
    series1Format.setPointLabelFormatter(new PointLabelFormatter());
    plot.addSeries(series1,series1Format);
    plot.setTicksPerRangeLabel(3);
    plot.getGraphWidget().setDomainLabelOrientation(-45);
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  DataHandler.getInstance().addObserver(this);
  mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
  if (DataHandler.getInstance().newValue) {
    mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
    if (!mBluetoothAdapter.isEnabled()) {
      new AlertDialog.Builder(this).setTitle(R.string.bluetooth).setMessage(R.string.bluetoothOff).setPositiveButton(android.R.string.yes,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          mBluetoothAdapter.enable();
          try {
            Thread.sleep(2000);
          }
 catch (          InterruptedException e) {
            e.printStackTrace();
          }
          listBT();
        }
      }
).setNegativeButton(android.R.string.no,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          searchBt=false;
        }
      }
).show();
    }
 else {
      listBT();
    }
    plot=(XYPlot)findViewById(R.id.dynamicPlot);
    if (plot.getSeriesSet().size() == 0) {
      Number[] series1Numbers={};
      DataHandler.getInstance().setSeries1(new SimpleXYSeries(Arrays.asList(series1Numbers),SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,"String_Node_Str"));
    }
    DataHandler.getInstance().setNewValue(false);
  }
 else {
    listBT();
    plot=(XYPlot)findViewById(R.id.dynamicPlot);
  }
  LineAndPointFormatter series1Format=new LineAndPointFormatter(Color.rgb(0,0,255),Color.rgb(200,200,200),null,null);
  series1Format.setPointLabelFormatter(new PointLabelFormatter());
  plot.addSeries(DataHandler.getInstance().getSeries1(),series1Format);
  plot.setTicksPerRangeLabel(3);
  plot.getGraphWidget().setDomainLabelOrientation(-45);
  t=GoogleAnalytics.getInstance(this).newTracker("String_Node_Str");
  t.setScreenName("String_Node_Str");
  t.send(new HitBuilders.AppViewBuilder().build());
}