Reputation: 11
I have getInstance
and a constructor in the same class, but I am not sure where I put my Init
method.
public class UploadService {
private Eng mEng;
private Context mContext;
private static UploadService INSTANCE;
private String appDir;
public static UploadService getInstance(Context context) {
if (null == INSTANCE) {
INSTANCE = new UploadService(context);
}
return INSTANCE;
}
public UploadService(Context context) {
this.mContext = context;
appDir=V8Utils.getAppDir(context);
}
public void init(Context cxt) {
mEng = new Eng(cxt);
mEng.init(appDir);
}
}
Upvotes: 1
Views: 351
Reputation: 24134
I would
init()
as private method.UploadService
object using the Context
object.I mean:
public UploadService(Context context) {
this.mContext = context;
appDir=V8Utils.getAppDir(context);
init(context);
}
private void init(Context cxt) {
mEng = new Eng(cxt);
mEng.init(appDir);
}
Upvotes: 2