提问人:Alex 提问时间:3/26/2023 更新时间:3/26/2023 访问量:36
人造人。将 AlertDialog EditText 中的值作为 Callable 的返回值传递
Android. Pass value from AlertDialog EditText as return value of Callable
问:
无法将用户输入中的代码作为返回值传递给 Callable。
LoginPresenter:
public void login(String username, String password) {
model.login(username, password,
new IGClient.Builder.LoginHandler() {
@Override
public LoginResponse accept(IGClient client, LoginResponse t) {
return IGChallengeUtils.resolveTwoFactor(client, t, new Callable<String>() {
@Override
public String call() throws Exception {
getView().showDialog(); // method from activity
return null; // here must be code that user entered
}
});
}
}
LoginActivity:
public void showDialog(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = getLayoutInflater().inflate(R.layout.request_code_dialog, null);
builder.setMessage("Write code from SMS");
builder.setView(view)
.setPositiveButton(R.string.okey_text,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
String code = ((EditText) view.findViewById(R.id.request_code_dialog_edittext_code)).getText().toString();
// ??? how to pass this code to Callable ???
}
}
);
AlertDialog alert = builder.create();
alert.show();
}
我试图通过Callback传递代码,但是如果我使用它,我无法将Callback的值设置为Callable的返回值。需要显示一个窗口,用于从SMS输入代码,并在用户单击后将此代码作为返回值传递以进行验证。
答: 暂无答案
评论