When my Json return is an array how can I get this array?

1
try{
                    URL urlConection = new URL(caminho);
                    conn = (HttpURLConnection) urlConection.openConnection();
                    conn.setDoOutput(true);
                    conn.setRequestMethod("POST");

                   /* DataOutputStream pt = new DataOutputStream(conn.getOutputStream());
                    pt.writeBytes(obj.toString());*/

                    PrintStream ps = new PrintStream(conn.getOutputStream());
                    ps.printf("json", obj.toString());

                    conn.connect();

                    //String resposta = decodifica(new String[]{new Scanner(conn.getInputStream()).next()});
                    String resposta = new Scanner(conn.getInputStream()).next();
                    Log.d("teste", obj.toString());

                    if(resposta.equals("1")){
                        Intent abreHome = new Intent(Login.this, Home.class);
                        startActivity(abreHome);
                    } else {
                        Toast.makeText(Login.this, "Ops houve um erro. Tente novamente", Toast.LENGTH_SHORT).show();
                        Log.d("retorno", resposta);
                    }


                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
asked by anonymous 31.03.2017 / 11:54

0 answers