Android - Error en activity

 
Vista:
sin imagen de perfil

Error en activity

Publicado por Maynor (2 intervenciones) el 06/01/2017 02:54:00
Buenas noches, tengo el problema que android studio me genera el apk, la aplicación me abre normal, cuando entro en especifico en la opción "ingresar" la aplicación se detiene, depure el código y me aparece esto

1
2
3
4
5
6
7
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
E/AndroidRuntime: FATAL EXCEPTION: Thread-5
                  Process: gt.eade.eadeapp, PID: 3435
                  java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.StringBuilder.toString()' on a null object reference
                      at gt.eade.eadeapp.logueo.enviarDatosGET(logueo.java:87)
                      at gt.eade.eadeapp.logueo$1.run(logueo.java:41)
Disconnected from the target VM, address: 'localhost:8601', transport: 'socket'
me podrian ayudar porfavor, adjunto el codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package gt.eade.eadeapp;
 
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
 
import org.json.JSONArray;
 
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
 
public class login extends AppCompatActivity implements View.OnClickListener {
 
    Button btningresar;
    EditText txtusu,txtpas;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
 
        txtusu=(EditText) findViewById(R.id.txtusu);
        txtpas=(EditText) findViewById(R.id.txtpas);
        btningresar=(Button) findViewById(R.id.btningresar);
 
        btningresar.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
 
        Thread tr=new Thread(){
            @Override
            public void run() {
                final String resultado=enviarDatosGET(txtusu.getText().toString(), txtpas.getText().toString());
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        int r = obtDatosJSON(resultado);
                        Toast.makeText(getApplicationContext(), r+"", Toast.LENGTH_LONG).show();
 
                        if (r > 0) {
                            Intent i = new Intent(getApplicationContext(), registroNotas.class);
                            i.putExtra("cod", txtusu.getText().toString());
                            startActivity(i);
                        } else {
                            Toast.makeText(getApplicationContext(), "Usuario o Pas Incorrectos", Toast.LENGTH_LONG).show();
                        }
                    }
                });
 
            }
        };
        tr.start();
    }
    public String enviarDatosGET(String usu, String pas){
 
        URL url=null;
        String linea="";
        int respuesta=0;
        StringBuilder resul=null;
 
        try{
            url=new URL("http://eade.tv/serviciosWeb/valida.php?usu="+usu+"&pas="+pas);
            HttpURLConnection conection=(HttpURLConnection)url.openConnection();
            respuesta=conection.getResponseCode();
 
            resul=new StringBuilder();
 
            if(respuesta==HttpURLConnection.HTTP_OK){
                InputStream in=new BufferedInputStream(conection.getInputStream());
                BufferedReader reader=new BufferedReader(new InputStreamReader(in));
 
                while((linea=reader.readLine())!=null){
                    resul.append(linea);
                }
            }
 
        }catch (Exception e){}
 
        return resul.toString();
 
    }
 
    public int obtDatosJSON(String response){
        int res=0;
        try{
            JSONArray json=new JSONArray(response);
            if(json.length()>0){
                res=1;
 
            }
 
        }catch(Exception e){}
        return res;
 
    }
 
 
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder