I know Bound Services Lives only until the Activity or any component needs it. We have to call the MyLocalBinder class from onBind function. Why is it so? Why can't we call it directly?
public class MyService extends Service {
private final IBinder myBinder = new MyLocalBinder();
public MyService() {
}
@Override
public IBinder onBind(Intent intent) {
return myBinder;
}
public String getCurrentTime(){
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss", Locale.UK);
return (df.format(new Date()));
}
public class MyLocalBinder extends Binder{
MyService getService(){
return MyService.this;
}
}
}