2
我有一種方法在活動中執行一些操作,而非活動類。我想知道何時完成非活動類網絡操作,以便我可以再次調用該方法。但是當我打電話給非活動類的時候,方法就結束了。這裏是我的代碼,..如何控制活動方法流程,直到非活動類執行網絡操作
public void somemethod(){
.
.
.
.
if (condition) {
new RegenerateToken().generate(DriverActivity.this); // calling non activity class which perform some network operation
//here i want to know that non activity class has performed the network operation so i can call this method again
}
.
.
.
log.d("method","ending");
}
非活性類
public class RegenerateToken {
public void generate(Context context) {
ExecuteServerReq executeServerReq = new ExecuteServerReq(context, client, Utilz.URL + "/authenticate", params, true, true);
executeServerReq.execute();
executeServerReq.getResponse = new ExecuteServerReq.GetResponse() {
@Override
public void onResponse(String objects) {
Utilz.printLog("RegenerateTokenresponse", objects);
}
};
}
}