public class GpsFuel extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
start = (Button)findViewById(R.id.Button01);
refresh = (Button)findViewById(R.id.Button03);
refresh.setOnClickListener(refreshListener);
start.setOnClickListener(startListener);
stop = (Button)findViewById(R.id.Button02);
stop.setOnClickListener(stopListener);
txt = (TextView)findViewById(R.id.TextView01);
txt1 = (TextView)findViewById(R.id.TextView02);
txt.setText("Waiting for distance");
ServiceConnection conn = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
IMyService myService = (IMyService) service;
distance = myService.getDistance();
String s = "la distanza è: " + distance;
int r = myService.getStatusCode();
Log.i("INFO", "Service bound ");}
public void onServiceDisconnected(ComponentName arg0) {
Log.i("INFO", "Service Unbound ");
private OnClickListener startListener = new OnClickListener() {
public void onClick(View v){
startService(new Intent(GpsFuel.this,GpsService.class));
private OnClickListener stopListener = new OnClickListener() {
public void onClick(View v){
stopService(new Intent(GpsFuel.this,GpsService.class));
private OnClickListener refreshListener = new OnClickListener() {
public void onClick(View v){