1、声明 (NetTool)
public DoSomething dosomething;
public void callBack(DoSomething doSomething){
this.dosomething=doSomething;
}
public interface DoSomething {
public void callBackIp(String string);
}
2、赋值 (NetTool)
if(dosomething!=null){
dosomething.callBackIp("MyTest+192.168.0.118");
}
3、调用 (GatewayActivity)
MyTest mytest=new MyTest();
mytest.callBack(new DoSomething() {
@Override
public void callBackIp(String string) {
System.out.println("回调的结果"+string);
}
});