java - Attempt to invoke interface method android -


this question has answer here:

i have code in class a

 private rtclistener mlistener;  @override public void update(string string) {     //here work want pass data interface           mlistener.onupdate(sometext);   }   public interface rtclistener{      void onupdate(string string);  } 

now in class , b

i implements interface

public class b extends service implements a.rtclistener{  // here override interface method   @override public void onupdate(string string) {   log.d("dwdwadwadwd"," data is"+string);  }    } 

its give me error

 attempt invoke interface method 'void .....  on null object reference 

i solve in class b

construct class

a in class b

a myclass = new a(this,another prameter if u have,another prameter if u have); 

and in class a on construct function this

public a(rtclistener l , other prameter , other prameter){ //construct method //rtclistener  interface name mlistener = l; } 

just sure code interface code above in question implements

that's :)


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -