点击(此处)折叠或打开
-
package org.lxh.demo;
-
import android.app.Service;
-
import android.content.Intent;
-
import android.os.IBinder;
-
public class MyServiceUtil extends Service { // 必须继承Service
-
@Override
-
public IBinder onBind(Intent intent) { // 绑定Activity
-
return null;
-
}
-
@Override
-
public void onCreate() { // 创建时调用
-
System.out.println("*** Service onCreate()");
-
}
-
@Override
-
public void onDestroy() { // 销毁时调用
-
System.out.println("*** Service onDestroy()");
-
}
-
@Override
-
public int onStartCommand(Intent intent, int flags, int startId) { // 开始Service
-
System.out.println("*** Service onStart() --> Intent = " + intent
-
+ " , startId = " + startId);
-
return Service.START_CONTINUATION_MASK ; // 继续执行Service
-
}
- }