Code example for Fragment

Methods: getActivity, onActivityCreated

0
    return(result);
  } 
 
  @Override 
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
 
    getActivity().getApplicationContext()
                 .bindService(new Intent(getActivity(),
                                         BshService.class), this,
                              Context.BIND_AUTO_CREATE);
  } 
 
  @Override 
  public void onDestroy() { 
    getActivity().getApplicationContext().unbindService(this);
    disconnect(); 
 
    super.onDestroy(); 
  }