How to use/locate LocalBroadcastManager
as described in google docs and Service broadcast doc?
I tried to google it, but there is no code available to s
we can also use interface for same as broadcastManger here i am sharing the testd code for broadcastManager but by interface.
first make an interface like:
public interface MyInterface {
void GetName(String name);
}
2-this is the first class that need implementation
public class First implements MyInterface{
MyInterface interfc;
public static void main(String[] args) {
First f=new First();
Second s=new Second();
f.initIterface(s);
f.GetName("Paddy");
}
private void initIterface(MyInterface interfc){
this.interfc=interfc;
}
public void GetName(String name) {
System.out.println("first "+name);
interfc.GetName(name);
}
}
3-here is the the second class that implement the same interface whose method call automatically
public class Second implements MyInterface{
public void GetName(String name) {
System.out.println("Second"+name);
}
}
so by this approach we can use the interface functioning same as broadcastManager.