I'm trying to code a AsyncTask, but AndroidStudio give me warn:
this Aynctask class should be static or leaks might occur
I found in stack 3 solution here: click :
asyncTasc static
weakReference
asyncListener
This topic is old, so for sure I ask: these solution are still 'on time' ?
Which of these solutions is professional and used in real projects?
My code:
@Override
public void onClick(View view) {
String loginFromUser = etLogin.getText().toString();
String passwordFromUser = etPassword.getText().toString();
GetUsers getUsers = new GetUsers();
getUsers.execute(loginFromUser, passwordFromUser);
}
.
private class GetUsers extends AsyncTask<String, Void, Void>{
@Override
protected Void doInBackground(String... strings) {
String login = strings[0];
String password = strings[1];
Log.w("Credentials: ", "" + login + password);
return null;
}
}