Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 意图不与if操作员Android一起工作_Java_Android - Fatal编程技术网

Java 意图不与if操作员Android一起工作

Java 意图不与if操作员Android一起工作,java,android,Java,Android,当我按下一个按钮将我重定向到一个页面时,它会显示一条消息,但它不起作用。成功后,将显示消息,但不会转发给我 private void registerUser() { try { Account account = new Account(); account.setpAddress(edt_adress.getText().toString()); account.setpBloodGroup(edt_blood.getSelected

当我按下一个按钮将我重定向到一个页面时,它会显示一条消息,但它不起作用。成功后,将显示消息,但不会转发给我

private void registerUser() {
    try {

        Account account = new Account();
        account.setpAddress(edt_adress.getText().toString());
        account.setpBloodGroup(edt_blood.getSelectedItem().toString());
        account.setpFirstName(edt_first.getText().toString());
        account.setpMidName(edt_mid.getText().toString());
        account.setpFamilyName(edt_fam.getText().toString());
        account.setpGender(edt_gender.getSelectedItem().toString());
        account.setpPhone(edt_phone.getText().toString());
        account.setpEgn(edt_egn.getText().toString());
        account.setuPassword(edt_password.getText().toString());
        account.setuUsername(edt_username.getText().toString());
        INodeJS accountservice = RetrofitClient.getInstance().create(INodeJS.class);
        Call call = accountservice.create(account);
        call.enqueue(new Callback() {
            @Override
            public void onResponse(Call call, Response response) {
                Account result = (Account) response.body();
                
                Toast.makeText(getApplicationContext(), result.getNotes(), Toast.LENGTH_LONG).show();
                if (result.getNotes().equals("Success")) {
                    Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                    startActivity(intent);
                }
                // startActivity(intent);
            }



            @Override
            public void onFailure(Call call, Throwable t) {
                Toast.makeText(getApplicationContext(), getString(R.string.createfield), Toast.LENGTH_SHORT).show();
            }
        });

    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
    }
}

看起来
result.getNotes().equals(“Success”)
不是真的,你认为舒尔应该是这样吗
equals
区分大小写,因此“success”不等于“success”,也不等于“success”-请注意空格

也许你可以试试这个说法:

result.getNotes().toLowerCase(Locale.getDefault()).trim().equals("success")
toLowerCase
将使您的所有字母大写,而
trim
将删除
字符串结尾处的所有空格

还有
equalsIgnoreCase
方法,因此它也可能如下所示:

result.getNotes().trim().equalsIgnoreCase("success")

那么,
if(result.getNotes().equals(“Success”){
这是真的吗?你的祝酒词在
onResponse
里面,而不是
如果
文本拼写正确。他尝试了你的例子,但仍然不起作用