Code example for Fragment

Methods: getActivity, onDestroy

0
                              this, Context.BIND_AUTO_CREATE);
  } 
 
  @Override 
  public void onDestroy() { 
    getActivity().getApplicationContext().unbindService(this);
 
    super.onDestroy(); 
  } 
 
  @Override 
  public void onClick(View view) {
    EditText script=(EditText)getView().findViewById(R.id.script);
    String src=script.getText().toString();
 
    try { 
      service.executeScript(src);
    } 
    catch (RemoteException e) {
      Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_LONG)
           .show();