android - Call methods on fragment - every object is null -


i have following problem:

i have 1 fragment, implements specified interface.

    @override public void sensorstatuschanged(double bearing, double pitch, double rotation) {     if (radarview != null) {         radarview.setbearing((float) bearing);     }     .... } 

the parentactivity handles location-listener , tries inform fragment sensordata has changed.

at part, have following behaviour: method gets called, radarview null. i'm 100% sure, radarview not null. when set breakpoints code, part radarview null, inside of methods, called activitiy , not fragment itself.

i'm total beginner in dealing fragments (started today), think i'm doing wrong.

how can solve behaviour?

cheers

okay, found mistake myself: i've created fragment in oncreate of activity. when change fragments, recreated fragments, without removing listener of old fragment..


Comments