AndroidRX - run method in background

前端 未结 5 1760
独厮守ぢ
独厮守ぢ 2021-02-12 15:38

I created simple activity with infinity progres bar, and I\'am trying to run time consuming method using RxJava to prevent UI thread from blocking, but everytime UI thread is bl

5条回答
  •  深忆病人
    2021-02-12 16:09

    kotlin use below code to work in background

     Single.fromCallable {
                      // method that run in background
    
              }
               .subscribeOn(Schedulers.io())
               .observeOn(AndroidSchedulers.mainThread())
               .subscribe()
    

提交回复
热议问题