title: use AIDL and return response to another app
body: <p>I using AIDL in a market project for payment and send score 
  and I return  orderID for checking result pay
  when developer send a request I send her request to the server and received orderID return to developers
  in fun resultPay I send a request to our server for getting result pay with the orderID while response has not returned I have to return the result</p>
  
  <pre><code>class DeveloperApiService : Service() {
  
  
  private val binder = object : ITiroDevApi.Stub() {
      override fun resultPay(token: String?, orderId: String?): String {
          var result = ""
          ServiceHelper.resultPayment(ActiveOwner(), GamerSharedPreferenceHelper(applicationContext).userID
                  , orderId, token,
                  object : CustomObserver&lt;ServiceHelper.StringResult&gt;() {
                      override fun onError(e: Throwable?) {
                          super.onError(e)
                          result = "tryAgain"
                      }
  
                      override fun onNext(response: ServiceHelper.StringResult?) {
                          super.onNext(response)
                          if (response!!.result != "") {
                              result = response.result
                          } else {
                              when (response.error) {
                                  "error_token_invalid_or_expired" -&gt; result = "error_token_invalid_or_expired"
                                  "error_payment_not_verified" -&gt; result = "error_payment_not_verified"
                              }
                          }
                      }
                  })
  
          if (result == "") Thread.sleep(2000)
          return result
  
      }
  
  
      override fun requestPay(token: String?, price: String?): String {
          var result = ""
          ServiceHelper.requestPayment(ActiveOwner(), token, GamerSharedPreferenceHelper(applicationContext).userID
                  , price,
                  object : CustomObserver&lt;ServiceHelper.StringResult&gt;() {
                      override fun onError(e: Throwable?) {
                          super.onError(e)
                          result = "tryAgain"
                      }
  
                      override fun onNext(response: ServiceHelper.StringResult?) {
                          super.onNext(response)
                          if (response!!.result != "") {
                              result = response.result
                              inAppPayment(GamerSharedPreferenceHelper(applicationContext).userID, response.result, token!!)
                          }
                          when (response.error) {
                              "error_token_invalid_or_expired" -&gt; result = "error_token_invalid_or_expired"
                              "error_min_amount" -&gt; result = "error_min_amount"
                          }
                      }
                  })
  
  
          while (result == "") {
              Thread.sleep(1000)
          }
          return result
      }
  
  private fun inAppPayment(userId: String, orderId: String, token: String) {
      var result = ""
      ServiceHelper.inAppPayment(ActiveOwner(), userId, orderId, token,
              object : CustomObserver&lt;ServiceHelper.StringResult&gt;() {
                  override fun onError(e: Throwable?) {
                      super.onError(e)
                  }
  
                  override fun onNext(response: ServiceHelper.StringResult?) {
                      super.onNext(response)
  
                      when (response.error) {
                          "error_already_pay" -&gt; result = ""
                          "error_payment_gateway" -&gt; result = "error_payment_gateway"
                      }
                      if (response.result != "") {
                          val browserIntent = Intent("android.intent.action.VIEW", Uri.parse(response.result))
                          applicationContext.startActivity(browserIntent)
                      }
                  }
              })
  
  }
  </code></pre>
  
  <p>What is your suggestion to solve this problem?</p>