Android how to runOnUiThread in other class?

后端 未结 6 1939
再見小時候
再見小時候 2020-11-28 08:22

In my application, in MainActivity, there is a thread which works fine. But when I call another class to get data from the server I can\'t run on a thread. See code exampl

6条回答
  •  时光取名叫无心
    2020-11-28 09:06

    If someone's looking for an Rx based solution:

    Observable.just(true)
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(aBoolean -> {
            // cool stuff comes here
        });
    

提交回复
热议问题