应用程序不适用于设备

时间:2012-08-21 02:43:53

标签: android web-services debugging

我创建了一个从Web服务读取数据的应用程序。但是当我试图在真实设备上运行它时。这是行不通的。它只是停在第一个屏幕上,除了应用程序的标题外没有显示任何内容。  似乎可以加载来自webserice的数据。我需要配置什么?

该应用具有互联网权限,但现在不需要,因为该服务在本地运行。任何想法或类似的经历?

主要课程:

public class Dashboard extends FragmentActivity implements OnClickListener, ClientDetailActivity.OnHeadlineSelectedListener {

Button btnConociendoAlCliente, btnMaterialDeApoyo, btnMaterialPromocional;

LinearLayout panelConociendoAlCliente, panelMaterialDeApoyo,
        panelMaterialPromocional, panelFragment;
Fragment listFragment;
ClientDetailActivity clientDetailActivity;

private ListView list;


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dashboard);

    initComponents();
}

public void initComponents() {

    panelFragment = (LinearLayout) findViewById(R.id.panelFragment);
    panelMaterialDeApoyo = (LinearLayout) findViewById(R.id.panelMaterialDeApoyo);
    panelMaterialPromocional = (LinearLayout) findViewById(R.id.panelMaterialPromocional);

    panelFragment.setVisibility(View.GONE);
    panelMaterialDeApoyo.setVisibility(View.GONE);
    panelMaterialPromocional.setVisibility(View.GONE);

    btnMaterialDeApoyo = (Button) findViewById(R.id.btnMaterialDeApoyo);
    btnMaterialPromocional = (Button) findViewById(R.id.btnMaterialPromocional);
    btnConociendoAlCliente = (Button) findViewById(R.id.btnConociendoAlCliente);

    btnConociendoAlCliente.setOnClickListener(this);
    btnMaterialDeApoyo.setOnClickListener(this);
    btnMaterialPromocional.setOnClickListener(this);

    clientDetailActivity = new ClientDetailActivity();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.add(R.id.listFragment, clientDetailActivity);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commit();

}

我的网络服务只是从关于客户端的db日期收集。这是代码:

HttpClient httpClient = new DefaultHttpClient();
        HttpGet del = new HttpGet(ruta + "s");
        del.setHeader("content-type", "application/json");

        try {
            HttpResponse resp = httpClient.execute(del);
            String respStr = EntityUtils.toString(resp.getEntity());
            JSONArray respJSON = new JSONArray(respStr);
            clientes = new String[respJSON.length()];

            for (int i = 0; i < respJSON.length(); i++) {

                JSONObject obj = respJSON.getJSONObject(i);

                // Log.e("nombre", idCli);
                ClienteDetallado clienteDetallado = new ClienteDetallado();

                try {
                    clienteDetallado.setCod_Medico(obj.getString("Cod_Medico"));
                } catch (Exception e) {
                    clienteDetallado.setCod_Medico("N/A");
                }

                try {
                    clienteDetallado.setNombre(obj.getString("Nombre"));
                } catch (Exception e) {
                    clienteDetallado.setNombre("N/A");
                }

                try {
                    clienteDetallado.setApellido(obj.getString("Apellido"));
                } catch (Exception e) {
                    clienteDetallado.setApellido("N/A");
                }


                clienteDetallados.add(clienteDetallado);
            }

            MyOwnArrayAdapter myOwnArrayAdapter = new MyOwnArrayAdapter(getActivity(), clienteDetallados);
            list.setAdapter(myOwnArrayAdapter);

        } catch (Exception ex) {
            Log.e("ServicioRest", "Error en listar!", ex);
        }

        return view;
    }

它位于上面片段的方法getView()中。 有一个HttpClient类使用的URL。 在模拟器中,一切正常。但不在设备中。

谢谢!

0 个答案:

没有答案