Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android


 
Herramientas
  #1  
Viejo 20/04/17, 05:22:44
Avatar de Andsenus
Andsenus Andsenus no está en línea
Usuario poco activo
Mensajes: 17
 
Fecha de registro: abr 2017
Mensajes: 17
Tu operador: Movistar
Mencionado: 0 comentarios
Tagged: 0 hilos
activity registro 1 y 2

Hola,tengo la siguiente duda.
ya resolvi mis php, entonces en la segunda parte del registro me pide USUARIO para identificar,en esta activity no se pide el USUARIO. la pregunta es.. como arrastro el USUARIO agregado en el edittext de la anterior activity a la siguiente activity sin que este sea visible.. o de ultima hago un BIENVENIDO "FULANO" y el fulano como un text view y que lo extraiga de ahi el json para la segunda parte (update).

EDITO: Consegui un codigo donde transfiere ese dato como String,pero no logro hacerlo funcionar.este es mi codigo:

Código:
continuar.setOnClickListener(new View.OnClickListener() {
              @override
            public void onClick(View v) {
                request = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
                      @override
                    public void onResponse(String response) {

                        try {
                            JSONObject jsonObject = new JSONObject(response);
                            if (jsonObject.names().get(1).equals("success")) {
                                Toast.makeText(getApplicationContext(), jsonObject.getString("success"), Toast.LENGTH_SHORT).show();
                                Intent a = new Intent(getApplicationContext(), register2.class);
                                a.putExtra("USER", Usuario.getText()+"");
                                startActivity(a);

                            }else {
                                Toast.makeText(getApplicationContext(),jsonObject.getString("error"), Toast.LENGTH_SHORT).show();
                            }
                        } catch (JSONException e)  {
                            e.printStackTrace();
                        }
sin trasladar ese dato la linea quedaria:

Código:
  Toast.makeText(getApplicationContext(), jsonObject.getString("success"), Toast.LENGTH_SHORT).show();
                                StartActivity = new Intent(getApplicationContext(), register2.class);

alguna idea de como arreglarlo?, por cierto,los datos ingresados se registran en la db sin problemas, el tema es que no puedo lanzar la siguiente activity arrastrando el USER.

SOLUCIONADO


El problema residía en la respuesta. puse get (1) y registraba y nada,lo cambie por un 0 y paso a register2.class
El tema del objeto no visible no pude encontrarle otra vuelta,en mi caso era posible hacer el View, y de igual manera el TextView va a estar presente en la siguiente activity,por ende el aprendizaje me sirvio. es hacer el intent con el putextra y luego rellenar el TV y obtenerlo de ahi..

dejo codigo por si alguien tuvo el mismo problema (los novatos como yo)

Código:
 Intent a = new Intent(register.this, register2.class);
                        a.putExtra("DATA_USER_KEY", Usuario.getText().toString());

                        try {
                            JSONObject jsonObject = new JSONObject(response);
                            if (jsonObject.names().get(0).equals("success")) {
                                Toast.makeText(getApplicationContext(), jsonObject.getString("success"), Toast.LENGTH_SHORT).show();
                                startActivity (a);
register2

Código:
  
 USER = (TextView) findViewById(R.id.Username);
        USER.setText(getIntent().getStringExtra("DATA_USER_KEY"));

-------------------------------------------------------------------------------------  @override
                    protected Map<String, String> getParams() throws AuthFailureError {
                        HashMap<String, String> hashMap = new HashMap<String, String>();
                        hashMap.put("USER", USER.getText().toString());


gracias

Última edición por Andsenus Día 22/04/17 a las 21:26:43 Razón: SOLUCIONADO
Responder Con Cita


Respuesta

Estás aquí
Regresar   HTCMania > Todo sobre Android > Programación y Desarrollo para Android


Reglas de Mensajes
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Las caritas están On
Código [IMG] está On
Código HTML está Off

Saltar a Foro



Hora actual: 01:09:32 (GMT +2)

Cookies settings
Powered by vBulletin™
Copyright © vBulletin Solutions, Inc. All rights reserved.
 
HTCMania: líderes desde el 2007