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

Respuesta
 
Herramientas
  #1  
Viejo 20/04/17, 05:22:44
Array

[xs_avatar]
Andsenus Andsenus no está en línea
Usuario poco activo
 
Fecha de registro: abr 2017
Mensajes: 17
Tu operador: Movistar

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   Portal | Indice > Todo sobre Android > Programación y Desarrollo para Android



Hora actual: 08:12:09 (GMT +2)



User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.

Contactar por correo / Contact by mail / 邮件联系 /