You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi ,
I'm currently using dagger 2 in my project. I'm unable to access injectable class through @Inject in non activity/fragment class. I have a handler class and want to use injectable in that class. Can u help me how to do this.
This is my ApplicationComponent class I added a method inject(APIHandler apiHandler) in this and tried getting @Injent DataManager dataManager(injectable class) in ApiHandler class but getting it null, any other thing i need to do in APIHandler class.Let me know if i m missing something where as i m able to get it in activity and fragment
APIHandler class
public class APIHandler {
/**
* Activity reference object
*/
private Activity mActivity;
/**
* Debug TAG
*/
private String TAG = APIHandler.class.getSimpleName();
@Inject
DataManager dataManager;
/**
* Public Constructor for this class
*
* @param mActivity
* @param webAPIResponseListener
*/
public APIHandler(Activity mActivity, WebAPIResponseListener webAPIResponseListener) {
this.mActivity = mActivity;
this.mResponseListener = webAPIResponseListener;
postAPICall();
}
//API call
public void postAPICall() {
//doing something
if(dataManager != null){
dataManager.setName();
}
}
The text was updated successfully, but these errors were encountered:
Hi ,
I'm currently using dagger 2 in my project. I'm unable to access injectable class through @Inject in non activity/fragment class. I have a handler class and want to use injectable in that class. Can u help me how to do this.
This is my ApplicationComponent class I added a method inject(APIHandler apiHandler) in this and tried getting @Injent DataManager dataManager(injectable class) in ApiHandler class but getting it null, any other thing i need to do in APIHandler class.Let me know if i m missing something where as i m able to get it in activity and fragment
APIHandler class
The text was updated successfully, but these errors were encountered: