Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.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 DataSnap Delphi XE3和Android 4.0没有函数返回选择?_Java_Android_Delphi - Fatal编程技术网

Java DataSnap Delphi XE3和Android 4.0没有函数返回选择?

Java DataSnap Delphi XE3和Android 4.0没有函数返回选择?,java,android,delphi,Java,Android,Delphi,当我使用datasnap在Delphi中创建的Web服务时,android版本4.0中出现了一个错误,在android版本2.0中运行平稳,在版本4.0中产生了更多异常,不知道为什么 “javaandroid.DBXException” Delphi中的我的选择 function TServerMethods1.GetDados_Clientes(Codigo: string; out Nome: string): string; var sSQL: string;

当我使用datasnap在Delphi中创建的Web服务时,android版本4.0中出现了一个错误,在android版本2.0中运行平稳,在版本4.0中产生了更多异常,不知道为什么 “javaandroid.DBXException”

Delphi中的我的选择

   function TServerMethods1.GetDados_Clientes(Codigo: string; out Nome: string): string;
    var
     sSQL: string;
     begin
        sSQL := ' SELECT CAST(CODIGO AS VARCHAR(30))AS CODIGO, NOME '+
           '   FROM CLIENTES '+
           '  WHERE ATIVO = ''Sim'' '+
           '  AND CAST(CODIGO AS VARCHAR(30)) = '+ QuotedStr(Codigo);  

        with CDS_Tabelas do
        begin
          Close;
          CommandText := sSQL;
          Open;
          Nome := FieldByName('CODIGO').AsString + ' - ' +  FieldByName('NOME').AsString;
          Result := Nome;
        end;
      end;
在生成embarcadero的java代理类中

  public static class GetDados_ClientesReturns {
     public String Nome;
     public String returnValue;
  }

  public GetDados_ClientesReturns GetDados_Clientes(String Codigo)
        throws DBXException {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("TServerMethods1.GetDados_Clientes");
     cmd.prepare(get_TServerMethods1_GetDados_Clientes_Metadata());
     cmd.getParameter(0).getValue().SetAsString(Codigo);
     getConnection().execute(cmd);
     GetDados_ClientesReturns ret = new GetDados_ClientesReturns();
     ret.Nome = cmd.getParameter(1).getValue().GetAsString();
     ret.returnValue = cmd.getParameter(2).getValue().GetAsString();
     return ret;
  }
function TServerMethods1.GetDados_Clientes(Codigo: string; out Nome: string): string;
我说要使用异步任务。,但我无法运行代码

   public class BuscaCliente extends AsyncTask<Void, Void, Void> {

    private ProgressDialog progress;
    private Context context;

    protected void onPreExecute() {
        // Cria novo um ProgressDialogo e exibe
        progress = new ProgressDialog(context);
        progress.setMessage("Aguarde...");
        progress.show();

    }

    protected Void doInBackground(Void... arg0) {
        DSRESTConnection conn = getConnection();
        TServerMethods1 serv = new TServerMethods1(conn);

        try {
            String idCharCodItem = edtCliente.getText().toString();
            String[] idNumItem = idCharCodItem.split("-");

            GetDados_ClientesReturns ret;
            ret = serv.GetDados_Clientes(idNumItem[0]);

            if (ret.Nome.equals(" - ")) {
                Alerta.mostrarAtencao(VendaClienteActivity.this,
                        getString(R.string.msg_clientenaolocalizado), 0,
                        false);
                carregando(false);
                // permanece no mesmo focus
                edtCliente.setText("");
                edtCliente.setFocusableInTouchMode(true);
                edtCliente.requestFocus();

            } else {
                // parametro = 0 significa 'Não', 1 significa 'Sim'
                if (parametroBLOQUEIA_CLIENTE_S_REG_ENTR() == 1) {
                    // ai verifica se o cliente tem registro do entrada
                    if (verificaIDCliente() != Integer
                            .parseInt(idNumItem[0])) {
                        Alerta.mostrarAtencao(
                                VendaClienteActivity.this,
                                getString(R.string.msg_clientesemregentrada),
                                0, false);
                        carregando(false);

                        // permanece no mesmo focus
                        edtCliente.setText("");
                        edtCliente.setFocusableInTouchMode(true);
                        edtCliente.requestFocus();
                    } else {
                        mudaFocusCliente();
                        // recebe o nome e o id do cliente
                        edtCliente.setText(ret.Nome);
                    }
                } else {
                    mudaFocusCliente();
                    // recebe o nome e o id do cliente
                    edtCliente.setText(ret.Nome);
                }
            }

        } catch (Exception e) {
            Toast.makeText(VendaClienteActivity.this, e.toString(),
                    Toast.LENGTH_LONG).show();
        }

        return null;
    }

    protected void onPostExecute(Void result) {
        progressDialog.dismiss();
    }

}

我是用这个密码来的

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.getWindow().clearFlags(
            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    setContentView(R.layout.tela_vendacli);

    // versão 4.0 android
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
            .permitAll().build();
    StrictMode.setThreadPolicy(policy);

谢谢你在他的方法声明中

  public static class GetDados_ClientesReturns {
     public String Nome;
     public String returnValue;
  }

  public GetDados_ClientesReturns GetDados_Clientes(String Codigo)
        throws DBXException {
     DSRESTCommand cmd = getConnection().CreateCommand();
     cmd.setRequestType(DSHTTPRequestType.GET);
     cmd.setText("TServerMethods1.GetDados_Clientes");
     cmd.prepare(get_TServerMethods1_GetDados_Clientes_Metadata());
     cmd.getParameter(0).getValue().SetAsString(Codigo);
     getConnection().execute(cmd);
     GetDados_ClientesReturns ret = new GetDados_ClientesReturns();
     ret.Nome = cmd.getParameter(1).getValue().GetAsString();
     ret.returnValue = cmd.getParameter(2).getValue().GetAsString();
     return ret;
  }
function TServerMethods1.GetDados_Clientes(Codigo: string; out Nome: string): string;
如果结果已经是,字符串不需要使用out,如果可以将put作为var,但不是必需的

function TServerMethods1.GetDados_Clientes(Codigo: string; var Nome: string): string;
重新生成代理并注意结果不为null或nil


代理没有或不会出错,但他不能为TJsonObject强制转换TJsonNull。

您在logcat中有stacktrace吗?请将其添加到您的问题中。有关StackOverflow的所有问题和答案都应使用英语。这仅仅是为了确保它们被尽可能广泛的受众所理解。如果你的英语不是很好,尽你最大的努力,其他用户可以编辑以改进语法/拼写等。