/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.showsugar); int exist = 1; // // double ig = gic.calculateGlycemicIndex(); estimator = BloodGlucoseEstimator.getInstance(); TextView sugarLevel = (TextView) findViewById(R.id.sugarLevel); try { sugarLevel.setText(String.format("%.2f", estimator.getlastValue(0))); drawEstimationGraph(); } catch (Exception e) { sugarLevel.setText(e.getMessage()); exist = 0; } Button refresh = (Button) findViewById(R.id.refresh); refresh.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { TextView sugarLevel = (TextView) findViewById(R.id.sugarLevel); try { sugarLevel.setText(String.format("%.2f", estimator.getlastValue(0))); drawEstimationGraph(); } catch (Exception e) { sugarLevel.setText(e.getMessage()); } } }); }