title: How to subscribe and unsubscribe or cancel an rxjava observable
body: <p>I am new in RxJava and trying to update my asyncTask works to RxJava. As a first try I have done the following codes:</p>
  
  <pre><code>    public class MainActivity extends AppCompatActivity 
      {
          @Override
          protected void onCreate(Bundle savedInstanceState) 
          {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
              doSomeWork();
          }
  
  
          private String funcCallServerGet()
          {
              //Some code to call a HttpClient Get method &amp; return a response string
              //this is the method which previously i used to call inside asynctask doInbackground method
          }
  
  
            private void doSomeWork() {
                 getSingleObservable()
                      .subscribeOn(Schedulers.io())
                      .observeOn(AndroidSchedulers.mainThread())
                      .subscribe(getSingleObserver())    ;
          }
  
  
          private Single&lt;String&gt; getSingleObservable() 
          {
              return Single.create(new SingleOnSubscribe&lt;String&gt;() {
                  @Override
                  public void subscribe(SingleEmitter&lt;String&gt; emitter) throws Exception {
                      if(!emitter.isDisposed()) {
                          String strRxResponse =  funcCallServerGet();
                          emitter.onSuccess(strRxResponse);
                      }
                  }
              });
          }
  
  
           private SingleObserver&lt;String&gt; getSingleObserver() 
          {
  
              return new SingleObserver&lt;String&gt;() {
                  @Override
                  public void onSubscribe(Disposable d) {
                      Log.d(TAG, " onSubscribe getSingleObserver: " + d.isDisposed());             }
  
                  @Override
                  public void onSuccess(String value) {
                      Log.d(TAG, " onNext : value : " + value);          }
  
                  @Override
                  public void onError(Throwable e) {
                      Log.d(TAG, " onError : " + e.getMessage());         }
              };
          }
  
      }
  </code></pre>
  
  <p>But I have some confusions:</p>
  
  <ol>
  <li><p>Why am I getting <em>false</em> in <strong>onSubscribe()</strong> of <strong>SingleObserver getSingleObserver()</strong> . </p></li>
  <li><p>How do I unsubscribe or cancel the observable/observer when activities onStop() is called.</p></li>
  <li><p>Also, what really happens when screen oriantation. Does the observable get unsubscribed automatically or it continues its work ? what to do for the device rotation ?</p></li>
  </ol>