I recently came across this fact:

Some devices that running on Android Pie overwrite previous one.

Toast toast1 = Toast.makeText(getApplicationContext(), "a", Toast.LENGTH_SHORT);
toast1.show();

Toast toast2 = Toast.makeText(getApplicationContext(), "b", Toast.LENGTH_SHORT);
toast2.show();

I don’t think Pie processes Toast message sequentially. It just shows last toast’s message only. (checked on my API 28 emulator)

with RxJava2 , Let’s do like this:

Toast[] toasts = {toast1, toast2};
Disposable disposable = Observable.interval(0, 3000, TimeUnit.MILLISECONDS)
        .map(Long::intValue)
        .map(i->toasts[i])
        .take(toasts.length)
        .subscribe(Toast::show);

카테고리: JavaRxJava

0개의 댓글

답글 남기기

Avatar placeholder

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다.