创建android的Service
2010-08-22 04:46:00 来源:WEB开发网bindbt.setOnClickListener(listener);
unbindbt.setOnClickListener(listener);
*/
}
}
SampleService.java
package com.android;
import android.app.Activity;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.os.Bundle;
public class SampleService extends Service{
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Log.d(TAG,"OnCreate");
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Log.d(TAG,"OnDestroy");
}
@Override
public void onRebind(Intent intent) {
// TODO Auto-generated method stub
super.onRebind(intent);
Log.d(TAG,"OnRebind");
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Log.d(TAG,"OnStart");
}
@Override
public boolean onUnbind(Intent intent) {
// TODO Auto-generated method stub
Log.d(TAG, "OnUnBind");
return super.onUnbind(intent);
}
final String TAG="Service";
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
Log.d(TAG,"OnBind");
return null;
}
}
赞助商链接