package com.czk.testview;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
public class ExampleService extends Service {
private static final String TAG="ExampleService";
private String str="";
public void onCreate() {
str="ExampleService-->onCreate";
Toast.makeText(ExampleService.this, str, Toast.LENGTH_SHORT).show();
Log.i(TAG, str);
super.onCreate();
}
public int onStartCommand(Intent intent, int flags, int startId) {
str="ExampleService-->onStartCommand";
Toast.makeText(ExampleService.this, str, Toast.LENGTH_SHORT).show();
Log.i(TAG, str);
return super.onStartCommand(intent, flags, startId);
}
public void onDestroy() {
str="ExampleService-->onDestroy";
Toast.makeText(ExampleService.this, str, Toast.LENGTH_SHORT).show();
Log.i(TAG, str);
super.onDestroy();
}
public IBinder onBind(Intent intent) {
str="ExampleService-->onBind";
Toast.makeText(ExampleService.this, str, Toast.LENGTH_SHORT).show();
Log.i(TAG, str);
return null;
}
}
Service的简单应用

最新推荐文章于 2021-04-08 13:06:35 发布