Questions tagged [rx-android]

RxJava bindings for Android

specific bindings for . RxAndroid module adds a number of classes to RxJava that make writing reactive components in Android applications easy and hassle free.

RxAndroid is open sourced and available under the Apache License, Version 2.0


Related tags

1768 questions
24
votes
1 answer

Why RxJava with Retrofit on Android doOnError() does not work but Subscriber onError does

can someone explain me why code like this: networApi.getList() .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .doOnError(throwable -> { throwable.getMessage(); …
wojciech_maciejewski
  • 1,277
  • 1
  • 12
  • 28
24
votes
3 answers

RxJava single background thread scheduler

I'm fairly new to RxJava so this is probably a dumb question. I am going to describe my scenario. I have some code running on the UI thread which will update some images but those images are not very important and they consume a bit of resources…
casolorz
  • 8,486
  • 19
  • 93
  • 200
23
votes
2 answers

How to use "if-else" in RX java chain?

I am a newer on RXJava/RXAndroid. I want to implement this case: chose different way based on some condition in RXJava. For example, first, I fetch user info from network and if this is a VIP user, I will go on to fetch more info from network or…
niu yi
  • 327
  • 1
  • 2
  • 6
23
votes
1 answer

Observable runs on main thread even though subscribeOn() is called on another thread

I got a weird issue in one of my activities. When coming back from taking a picture / video, in my onActivityResult I am showing a dialog that lets the user name the camera. Once the user presses OK, I send onNext() to a subject with the requested…
Yoshkebab
  • 770
  • 1
  • 7
  • 14
23
votes
1 answer

Process Observable on background thread

I am using RxAndroid for stream operations. In my real use-case, i am fetching a list from the server (using Retrofit). I am using schedulers to do the work on a background thread and get the final emission on the Android UI (main) thread. This…
WonderCsabo
  • 11,947
  • 13
  • 63
  • 105
20
votes
1 answer

RxJava onError Can't create handler inside thread that has not called Looper.prepare()

first i will try to explain what im trying to do, next you will see what im doing(code). Since im new at RxJava, and still learning fell free to give me your opinion. So, im calling a network API from server and when start request i call…
user1851366
  • 256
  • 6
  • 20
  • 41
20
votes
4 answers

How do I handle exceptions in map() in an Observable in RxJava

I want to do this: Observable.just(bitmap) .map(new Func1() { @Override public File call(Bitmap photoBitmap) { //File creation throws IOException, …
Sree
  • 2,727
  • 3
  • 29
  • 47
19
votes
3 answers

Using Consumer interface of Reactivex

I'm new to ReactiveX. I was learning it from reading source-code. Everything was so clear but suddenly I got this word named "Consumer" which was an Interface. It was used in place of Observer. Can someone let me know what it exactly does? I…
Abhishek Kumar
  • 4,532
  • 5
  • 31
  • 53
19
votes
3 answers

RxJava + Retrofit -> BaseObservable for API calls for centralized response handling

I am new to RxJava so please forgive me if this sounds too newbie :-). As of now I have an abstract CallbackClass that implements the Retofit Callback. There I catch the Callback's "onResponse" and "onError" methods and handle various error types…
GuyZ
  • 686
  • 1
  • 10
  • 25
19
votes
3 answers

Rx Java mergeDelayError not working as expected

I'm using RxJava in and Android application with RxAndroid. I'm using mergeDelayError to combine two retro fit network calls into one observable which will process emitted items if either emits one and the error if either has one. This is not…
Bobbake4
  • 24,509
  • 9
  • 59
  • 94
19
votes
3 answers

Convert AsyncTask to RxAndroid

I have the following method to post response to UI using otto and AsyncTask. private static void onGetLatestStoryCollectionSuccess(final StoryCollection storyCollection, final Bus bus) { new AsyncTask() { @Override …
Fshamri
  • 1,346
  • 4
  • 17
  • 32
18
votes
3 answers

How can I make this rxjava zip to run in parallel?

I have a sleep method for simulating a long running process. private void sleep() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } Then I have a method returns an Observable…
s-hunter
  • 24,172
  • 16
  • 88
  • 130
18
votes
2 answers

Queuing tasks with RxJava in Android

I'm developing application for Android with background data synchronization. I'm currently using RxJava to post some data on server in regular intervals. Other than that, I'd like to provide user with a button "force sync" which will trigger sync…
Darko Smoljo
  • 335
  • 4
  • 10
18
votes
2 answers

How to update UI from Android service using RxJava/RxAndroid

I have a Bound Service which responsible for downloading files and thus it knows the downloading status/progress. And the UI (Fragment or Activity) has to show/update download progress from the service. Actually i think the common way is to use…
18
votes
5 answers

Observable, retry on error and cache only if completed

we can use the cache() operator to avoid executing a long task (http request) multiple times, and reuse its result: Observable apiCall = createApiCallObservable().cache(); // notice the .cache() --------------------------------------------- // the…
Plato
  • 2,338
  • 18
  • 21