क्या कोई तरीका है जब मेरे रेट्रोफिट कॉल ने अपना कर्तव्य पूरा कर लिया है? मुझे पता है कि जब सभी डेटा प्राप्त होता है तो कोड आगे बढ़ सकता है, जैसे कि दूसरी गतिविधि शुरू करने या दूसरी कॉल करने के लिए पहले कॉल से डेटा का उपयोग करना?कैसे पता चलेगा कि रेट्रोफिट कॉल कब समाप्त हो गया है
Ps .: मैं एक एसिंक्रोनस अनुरोध (.enqueue) का उपयोग कर रहा हूं।
संपादित करें:
getContact(){
//Get a contact List from the server
Call<List<ModelContact>> callM = contactInterface.createRContact(listContact);
callM.enqueue(new Callback<List<ModelContact>>() {
@Override
public void onResponse(Response<List<ModelContact>> response, Retrofit retrofit) {
// Fetch the List from Response and save it on the local database
}
@Override
public void onFailure(Throwable t) {
Log.i("TAG", "Error: " + t.getMessage());
}
});
//Gets a object containing some configurations
Call<Configs> callC = contactInterface.getConfigs(Configs);
callC.enqueue(new Callback<Configs>() {
@Override
public void onResponse(Response<Configs> response, Retrofit retrofit) {
// Fetch the Configs object and save it on the database
}
@Override
public void onFailure(Throwable t) {
Log.i("TAG", "Error: " + t.getMessage());
}
});
//Here I need to start a new activity after the calls
Intent loginact = new Intent(TokenActivity.this, LoginActivity.class);
startActivity(loginact);
}
आप enqueue को (उर्फ श्रोता) एक प्रतिनिधि प्रदान कर सकते हैं। – Blackbelt
मुझे कोड नमूना कहां मिल सकता है, मैंने इसे गोगल किया है और कुछ भी नहीं मिला है ... – Rafael
आप अपना प्रयास क्यों नहीं पोस्ट करते? – Blackbelt