Android Server类
2010-10-19 20:17:26 来源:WEB开发网在 LOG 中显示进程
view plaincopy to clipboardprint?
1. package my.android.AppServer;
2.
3. import android.app.Activity;
4. import android.content.Intent;
5. import android.os.Bundle;
6. import android.view.View;
7. import android.widget.Button;
8.
9. public class AppServer extends Activity implements android.view.View.OnClickListener {
10.
11. private Button mButton1, mButton2;
12.
13. /** Called when the activity is first created. */
14. @Override
15. public void onCreate(Bundle savedInstanceState) {
16. super.onCreate(savedInstanceState);
17. setContentView(R.layout.main);
18.
19. mButton1 = (Button) findViewById(R.id.button1_id);
20. mButton1.setOnClickListener(this);
21.
22. mButton2 = (Button) findViewById(R.id.button2_id);
23. mButton2.setOnClickListener(this);
24. }
25.
26. public void onClick(View v) {
27. // TODO Auto-generated method stub
28.
29. switch (v.getId()) {
30. case R.id.button1_id:
31. Intent i = new Intent(this, mService.class);
32. i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
33. startService(i);
34. break;
35. case R.id.button2_id:
36. Intent i2 = new Intent(this, mService.class);
37. stopService(i2);
38. break;
39. default:
40. break;
41. }
42. }
43. }
package my.android.AppServer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class AppServer extends Activity implements android.view.View.OnClickListener { private Button mButton1, mButton2; /**
更多精彩
赞助商链接