我有A和B类。 “ A”成为“ B”的实例,并调用修改String属性的方法。但是,调用后,“ A”中签入的属性为空。 谁能帮我吗?
Class B
private String Retro;
....
public boolean Login(final String user,final String pass){
stringRequest = new StringRequest(Request.Method.POST,Url + strLogin,new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Display the first 500 characters of the response string.
Retro = "Done";
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
**Retro = error.getMessage();**
Toast.makeText(context,"Error de acceso: "+Retro,Toast.LENGTH_LONG).show(); //error.getMessage()
}
}) {
@Override
protected Map<String,String> getParams(){
Map<String,String> parameters = new HashMap<>();
parameters.put("identifier",user);
parameters.put("password",pass);
return parameters;
}
};
// Add the request to the RequestQueue.
requestQueue.add(stringRequest);
return Retro == "Done";
}
Class A
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportactionBar(toolbar);
FloatingactionButton fab = findViewById(R.id.fab);
fab.setOnClicklistener(new View.OnClicklistener() {
@Override
public void onClick(View view) {
snackbar.make(view,"Replace with your own action",snackbar.LENGTH_LONG)
.setaction("action",null).show();
}
});
accessDB = new StrapiDBaccess(this);
signIn();
}
private void handleSignInResult(Task<GoogleSignInaccount> completedTask) {
try {
...
if (acct != null) {
....
boolean result = accessDB.Login(parcelaccess.personEmail,"*******");
tvAuth.setText(tvAuth.getText()+" "+**accessDB.getRetro()**); //
}
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
parcelaccess.signedIn = false;
parcelaccess.personName = "Anónimo";
Toast.makeText(this,"Error de autenticación con Google. Chequee que tiene internet e inténtelo de nuevo.",Toast.LENGTH_SHORT).show();
}
}