我已经设置了服务类,我有一个类调用UserLocation,需要在后台运行,如何使用' iBinder'方法
public class MyServices extends Service {
@Override
public IBinder onBind(Intent intent) { //Sets up the specific service to be running in the background
throw new UnsupportedOperationException("Not Yet Implemented");
}
@Override
public void onCreate() {
Toast.makeText(this, "Service Created", Toast.LENGTH_SHORT).show();
} //Send an alert message showing the service is created
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//This service will keep running until it is stopped(below) when clicked
Toast.makeText(this, "Service Working", Toast.LENGTH_SHORT).show();
return START_STICKY;
}
@Override
public void onDestroy() {//Destroys the service/stops it from running in the background if clicked
super.onDestroy();
Toast.makeText(this, "Service Stopped", Toast.LENGTH_SHORT).show();
}
}