0
This code is only returning null the Return, how can I fix it?
@SuppressWarnings("deprecation")
public class MecanismoString extends AsyncTask <String, String, String> {
@SuppressLint("StaticFieldLeak")
private Context context;
private Interface execinterface;
private String retorno;
MecanismoString (Context context, Interface execinterface){
this.context = context;
this.execinterface = execinterface;
}
@Override
public String doInBackground(String... params) {
Ion.with(context)
.load(params[1])
.setBodyParameter("login", params[2])
.setBodyParameter("senha", params[3])
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject resultado) {
retorno = resultado.get("perfil").getAsString();
}
});
return retorno;
}
public void onPostExecute(String retorno) {
execinterface.carregarString(retorno);
}
}
when I use debug to read the code
retorno = resultado.get("perfil").getAsString();
it returns the correct bd value, but onPostExecute only reads null..
Dear Tiaho, this seems to me Java does not https://ion-lang.org, or did I get something wrong?
– Guilherme Nascimento
@Guilhermenascimento Ion, in this case, is a lib/api
– ramaral
@ramaral that’s right, I think I can understand that the title of the question sounds strange, since it is an API has no sense to write "Ion language", agree? And the lack of tag on the question can still confuse more. I understand that we do not have the tag as in Soen: https://stackoverflow.com/questions/tagged/ion to have a wiki and a brief description, but the biggest problem is the beginning of the title ;)
– Guilherme Nascimento