title: Return String from a Method after RxJava call
body: <p>i am having a problem to return a value after i call a Service from the Backend, it is a String i get from the Service and after i call this service i want that method to return me that string</p>
  
  <p>I have tried saving it in a variable, saving it in sharedpreference but it always returns me an empty string. Yet when i Log.d the result i get from the service i can see that it returns me the thing i want but i want the Method then to return me that result</p>
  
  <pre class="lang-java prettyprint-override"><code>    fun getExchangePortalToken(): String {
  //I want this variable to be the value of the String i get from the Service and to return it afterwards
          var token = ""
          compositeDisposable!!.add(apiServicePortal!!.getExchangeToken(basic, "casopenid-bearer", idToken)
                  .subscribeOn(Schedulers.io())
                  .observeOn(AndroidSchedulers.mainThread())
                  .subscribeWith(object: DisposableSingleObserver&lt;Response&lt;ResponseBody&gt;&gt;(){
                      override fun onSuccess(value: Response&lt;ResponseBody&gt;?) {
                          Log.d("EXCHANGE_PORTAL", "SUCCESS")
  
                          val string = value!!.body()!!.string()
                          val obj = JSONObject(string)
                          var access_token = obj.getString("access_token")
  
  //Here im setting the value of the string based on the Result i get from the service
                          token = access_token
                      }
  
                      override fun onError(e: Throwable?) {
                          Log.d("EXCHANGE_PORTAL", e!!.message)
                          token = "ERROR"
                      }
  
                  }))
          return token
      }
  
  </code></pre>