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

Android Service 笔记

 2010-08-22 04:47:00 来源:WEB开发网   
核心提示:information about that work into persistent storage during the onStart() call so that it does not get lost if the service later gets killed.Other application co
information about that work into persistent storage during the onStart() call so that it does not get lost if the service later gets killed.

Other application components running in the same process as the service (such as an Activity) can, of course, increase the importance of the overall process beyond just the importance of the service itself.

package test.service;

import android.app.Service;

import android.content.Intent;

import android.os.Binder;

import android.os.IBinder;

import android.util.Log;

public class MyTestService extends Service {

private static final String TAG = "MyTestService";

@Override

public IBinder onBind(Intent intent) {

// TODO Auto-generated method stub

Log.d(TAG, "onBind(Intent intent) called");

return null;

}

@Override

public void onCreate() {

// TODO Auto-generated method stub

super.onCreate();

Log.d(TAG, "onCreate() called");

}

@Override

public void onDestroy() {

// TODO Auto-generated method stub

super.onDestroy();

Log.d(TAG, "onDestroy() called");

}

@Override

public void onStart(Intent intent, int startId) {

// TODO Auto-generated method stub

super.onStart(intent, startId);

Log.d(TAG, "onStart(Intent intent, int startId) called");

}

@Override

public boolean onUnbind(Intent intent) {

// TODO Auto-generated method stub

Log.d(TAG, "onUnbind(Intent intent) called");

return super.onUnbind(intent);

}

public class LocalBinder extends Binder {

public MyTestService getService() {

return MyTestService.this;

}

}

}

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

Tags:Android Service 笔记

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