WEB开发网
开发学院手机开发Android 开发 Android Service 笔记 阅读

Android Service 笔记

 2010-08-22 04:47:00 来源:WEB开发网   
核心提示:package test.service;import android.app.Activity;import android.content.ComponentName;import android.content.Context;import android.content.Intent;import androi

package test.service;

import android.app.Activity;

import android.content.ComponentName;

import android.content.Context;

import android.content.Intent;

import android.content.ServiceConnection;

import android.os.Bundle;

import android.os.IBinder;

import android.util.Log;

import android.view.View;

import android.widget.Button;

public class ServiceDemo extends Activity {

private static final String TAG = "ServiceDemo";

private Button mBtnStart, mBtnStop, mBtnBind, mBtnUnbind;

private MyTestService mService;

private boolean isBinded;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

mBtnStart = (Button) findViewById(R.id.btnStartService);

mBtnStop = (Button) findViewById(R.id.btnStopService);

mBtnBind = (Button) findViewById(R.id.btnBindService);

mBtnUnbind = (Button) findViewById(R.id.btnUbindService);

mBtnStart.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

startService();

}

});

mBtnStop.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

stopService();

}

});

mBtnBind.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

bindService();

}

});

mBtnUnbind.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

unbindService();

}

});

上一页  1 2 3 4 5 6 7  下一页

Tags:Android Service 笔记

编辑录入:coldstar [复制链接] [打 印]
赞助商链接