Hello I am making an application where I am trying to define the constant using enum
and trying to access those constants in the switch case of the doInBackGround
method of AsynTask
but there it saying me
LOGIN_API_CALL cannot be resolved to a variable
public class TeemWurkAsyncTask extends AsyncTask<String, Void, String> {
private enum WebAPIConstants {
LOGIN_API_CALL, FORGOT_PASSWORD_API_CALL;
}
private ProgressDialog mProgressDialog;
private Context mContext;
private TaskCompleteListener taskCompleteListener;
private int method;
public TeemWurkAsyncTask(TaskCompleteListener taskCompleteListener, int method) {
this.taskCompleteListener = taskCompleteListener;
this.method = method;
}
@Override
protected void onPreExecute() {
mProgressDialog = new ProgressDialog(mContext);
mProgressDialog.setTitle(mContext.getString(R.string.app_name));
mProgressDialog.setMessage(mContext.getString(R.string.please_wait));
mProgressDialog.setProgressStyle(mProgressDialog.STYLE_SPINNER);
mProgressDialog.setIndeterminate(true);
mProgressDialog.show();
}
@Override
protected String doInBackground(String... params) {
switch(method) {
case LOGIN_API_CALL: <---- Here getting an error "LOGIN_API_CALL cannot be resolved to a variable"
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
}
}
Please help me and thanks in advance.