Comments (7)
额,我现在oncreate调用 RxLife.with(this),初始化之后就不会出现这个问题了。。
from rxlife.
Attempt to invoke virtual method 'void io.reactivex.subjects.Subject.onNext(java.lang.Object)' on a null object reference,其他地方还是会报错。
from rxlife.
你调用代码我看一下,是否添加依赖 RxJava2,我看了代码,此处调用的是 lifecycleSubject.onNext()方法,lifecycleSubject已经在类实例化的时候初始化了 lifecycleSubject,点击查看LifecycleBridge代码,另外在Activity里使用有问题吗 ?是不是Fragment 的问题,Fragment只能是v4包下的 Fragment
from rxlife.
@huangxumin Fragment应该是动态添加的吧 ?
from rxlife.
有添加rxjava2依赖,activity也会出现这个问题,我觉得不是fragment的问题。我跳转activity也会出现这个问题。fargment是动态添加的
//判断此Fragment是否已经添加到FragmentTransaction事物中
if (!fragment.isAdded()) {
ft.add(R.id.fragment, fragment, fragment.getClass().getName());
} else {
ft.show(fragment);
}
是v4的fragment,activity继承fragmentAvtivity.
这是activity和fragmrnt的调用代码:
注释的rxlife,我现在用RxLifecycle测试。
baseActivity里面:
public <T> LifecycleTransformer<T> bindToLifecycle() {
// return RxLife.with(this).bindOnDestroy();
return RxLifecycle.with(this).bindOnDestroy();
}
调用:
RxView.clicks(back).throttleFirst(1, TimeUnit.SECONDS).compose(bindToLifecycle())
.subscribe(new Consumer() {
@OverRide
public void accept(Unit o) throws Exception {
onBackPressed();
}
});
from rxlife.
原因我已经查到,类加载构造方法执行顺序的问题,可能会导致这个问题,我正在解决,随后发布代码
from rxlife.
你试一下使用最新的1.1.3版本,能否解决问题
from rxlife.
Related Issues (4)
- RuntimeException HOT 8
- Gradle加载报错 HOT 1
- 楼主,怎么没有升级到支持Androidx的?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxlife.