实例示范如何使用 Android Services
2010-03-03 15:48:00 来源:WEB开发网核心提示:buttonStart = (Button) findViewById(R.id.buttonStart);buttonStop = (Button) findViewById(R.id.buttonStop);buttonStart.setOnClickListener(this);buttonStop.setOnC
buttonStart = (Button) findViewById(R.id.buttonStart);
buttonStop = (Button) findViewById(R.id.buttonStop);
buttonStart.setOnClickListener(this);
buttonStop.setOnClickListener(this);
}
public void onClick(View src) {
switch (src.getId()) {
case R.id.buttonStart:
Log.d(TAG, “onClick: starting srvice”);
startService(new Intent(this, MyService.class));
break;
case R.id.buttonStop:
Log.d(TAG, “onClick: stopping srvice”);
stopService(new Intent(this, MyService.class));
break;
}
}
}
更多精彩
赞助商链接