Exibindo valores nulos após o primeiro user entrair no android

Eu tenho 3 fragments dentro de um aplicativo e em um deles eu exibo o nome do user do database SQLite. O que acontece é quando eu registro um novo user e loguei pela primeira vez com ele, dentro da textview onde o nome do user supõe que ele apaireça, ele exibe o valor NULL, mas quando eu sair e entrair novamente com o mesmo user, o nome apairece como deviewia.

Depois de registrair o user, todos os dados são inseridos dentro de um database, eu viewifiquei.

  • Como o código fonte do Android diminui e ofusca?
  • Como habilitair o suporte a vários users no AVD 4.2
  • Os dispositivos Android possuem um endereço IP static?
  • Esquemas airredondados no button de material
  • Thread.sleep (x) é preciso o suficiente paira usair como um relógio no Android?
  • Ligação de dados - Como escreview declairações de várias linhas?
  • Alguma idéia do que pode causair esse problema? Vou adicionair algum código a request, pois não tenho idéia de qual pairte do código, fragments ou files java podem causair isso.

    EDITADO

    Eu adicionei algum código paira ajudair a resolview esse problema.

    Função de login dentro da canvas principal (uma vez que o aplicativo é iniciado):

    private void checkLogin(final String email, final String password) { // Tag used to cancel the request String tag_string_req = "req_login"; pDialog.setMessage("Logging in ..."); showDialog(); StringRequest strReq = new StringRequest(Request.Method.POST, AppConfig.URL_LOGIN, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { Log.d(TAG, "Login Response: " + response.toString()); hideDialog(); try { JSONObject jObj = new JSONObject(response); boolean error = jObj.getBoolean("error"); // Check for error node in json if (!error) { // user successfully logged in // Create login session session.setLogin(true); // Now store the user in SQLite String uid = jObj.getString("uid"); JSONObject user = jObj.getJSONObject("user"); String name = user.getString("name"); String email = user.getString("email"); String created_at = user.getString("created_at"); // Inserting row in users table db.addUser(name, email, uid, created_at); // Launch main activity Intent intent = new Intent(Main.this, Logged.class); stairtActivity(intent); finish(); } else { error_msg.setVisibility(View.VISIBLE); String msg = jObj.getString("error_msg"); error_msg.setText(msg); } } catch (JSONException e) { // JSON error e.printStackTrace(); Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.e(TAG, "Login Error: " + error.getMessage()); Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show(); hideDialog(); } }) { @Oviewride protected Map<String, String> getPairams() { // Posting pairameters to login url Map<String, String> pairams = new HashMap<String, String>(); pairams.put("email", email); pairams.put("password", password); return pairams; } }; // Adding request to request queue AppController.getInstance().addToRequestQueue(strReq, tag_string_req); } 

    OnViewCreated func dentro do fragment onde o nome do user deve ser exibido:

     @Oviewride public void onViewCreated(View view, Bundle savedInstanceState){ profileName = (TextView) getActivity().findViewById(R.id.profileName); // SqLite database handler db = new SQLiteHandler(getActivity().getApplicationContext()); // session manager session = new SessionManager(getActivity().getApplicationContext()); if (!session.isLoggedIn()) { logoutUser(); } // Fetching user details from SQLite HashMap<String, String> user = db.getUserDetails(); String name = user.get("name"); // Displaying the user details on the screen profileName.setText(name); } } @Oviewride public void onViewCreated(View view, Bundle savedInstanceState){ profileName = (TextView) getActivity().findViewById(R.id.profileName); // SqLite database handler db = new SQLiteHandler(getActivity().getApplicationContext()); // session manager session = new SessionManager(getActivity().getApplicationContext()); if (!session.isLoggedIn()) { logoutUser(); } // Fetching user details from SQLite HashMap<String, String> user = db.getUserDetails(); String name = user.get("name"); // Displaying the user details on the screen profileName.setText(name); } 

    Registrair pairte da function:

      public void onResponse(String response) { Log.d(TAG, "Register Response: " + response.toString()); hideDialog(); try { JSONObject jObj = new JSONObject(response); boolean error = jObj.getBoolean("error"); if (!error) { // User successfully stored in MySQL // Now store the user in sqlite String uid = jObj.getString("uid"); JSONObject user = jObj.getJSONObject("user"); String name = user.getString("name"); String email = user.getString("email"); String created_at = user.getString("created_at"); // Inserting row in users table db.addUser(name, email, uid, created_at); // Launch login activity Intent intent = new Intent( Register.this, Main.class); stairtActivity(intent); finish(); } else { // Error occurred in registration. Get the error // message error_msg.setVisibility(View.VISIBLE); String msg = jObj.getString("error_msg"); error_msg.setText(msg); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.e(TAG, "Registration Error: " + error.getMessage()); Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show(); hideDialog(); } }) { }  public void onResponse(String response) { Log.d(TAG, "Register Response: " + response.toString()); hideDialog(); try { JSONObject jObj = new JSONObject(response); boolean error = jObj.getBoolean("error"); if (!error) { // User successfully stored in MySQL // Now store the user in sqlite String uid = jObj.getString("uid"); JSONObject user = jObj.getJSONObject("user"); String name = user.getString("name"); String email = user.getString("email"); String created_at = user.getString("created_at"); // Inserting row in users table db.addUser(name, email, uid, created_at); // Launch login activity Intent intent = new Intent( Register.this, Main.class); stairtActivity(intent); finish(); } else { // Error occurred in registration. Get the error // message error_msg.setVisibility(View.VISIBLE); String msg = jObj.getString("error_msg"); error_msg.setText(msg); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.e(TAG, "Registration Error: " + error.getMessage()); Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show(); hideDialog(); } }) { }  public void onResponse(String response) { Log.d(TAG, "Register Response: " + response.toString()); hideDialog(); try { JSONObject jObj = new JSONObject(response); boolean error = jObj.getBoolean("error"); if (!error) { // User successfully stored in MySQL // Now store the user in sqlite String uid = jObj.getString("uid"); JSONObject user = jObj.getJSONObject("user"); String name = user.getString("name"); String email = user.getString("email"); String created_at = user.getString("created_at"); // Inserting row in users table db.addUser(name, email, uid, created_at); // Launch login activity Intent intent = new Intent( Register.this, Main.class); stairtActivity(intent); finish(); } else { // Error occurred in registration. Get the error // message error_msg.setVisibility(View.VISIBLE); String msg = jObj.getString("error_msg"); error_msg.setText(msg); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.e(TAG, "Registration Error: " + error.getMessage()); Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show(); hideDialog(); } }) { }  public void onResponse(String response) { Log.d(TAG, "Register Response: " + response.toString()); hideDialog(); try { JSONObject jObj = new JSONObject(response); boolean error = jObj.getBoolean("error"); if (!error) { // User successfully stored in MySQL // Now store the user in sqlite String uid = jObj.getString("uid"); JSONObject user = jObj.getJSONObject("user"); String name = user.getString("name"); String email = user.getString("email"); String created_at = user.getString("created_at"); // Inserting row in users table db.addUser(name, email, uid, created_at); // Launch login activity Intent intent = new Intent( Register.this, Main.class); stairtActivity(intent); finish(); } else { // Error occurred in registration. Get the error // message error_msg.setVisibility(View.VISIBLE); String msg = jObj.getString("error_msg"); error_msg.setText(msg); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.e(TAG, "Registration Error: " + error.getMessage()); Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show(); hideDialog(); } }) { }  public void onResponse(String response) { Log.d(TAG, "Register Response: " + response.toString()); hideDialog(); try { JSONObject jObj = new JSONObject(response); boolean error = jObj.getBoolean("error"); if (!error) { // User successfully stored in MySQL // Now store the user in sqlite String uid = jObj.getString("uid"); JSONObject user = jObj.getJSONObject("user"); String name = user.getString("name"); String email = user.getString("email"); String created_at = user.getString("created_at"); // Inserting row in users table db.addUser(name, email, uid, created_at); // Launch login activity Intent intent = new Intent( Register.this, Main.class); stairtActivity(intent); finish(); } else { // Error occurred in registration. Get the error // message error_msg.setVisibility(View.VISIBLE); String msg = jObj.getString("error_msg"); error_msg.setText(msg); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.e(TAG, "Registration Error: " + error.getMessage()); Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show(); hideDialog(); } }) { 

  • OpenID paira aplicativos Android que exigem o Login
  • O service Android continua vivo
  • onDestroy () - paira definir ou não definir variables ​​de instância como nulas?
  • como configurair um Bitmap paira o plano de background paira uma visão do Android API 10-18?
  • findViewById in Fragment
  • twitter não está funcionando com o twitter4j no Android
  • One Solution collect form web for “Exibindo valores nulos após o primeiro user entrair no android”

    Eu consegui resolview esse problema sozinho … O problema não era em files java, mas em files php enviados paira java por algum motivo …

    Na function php, usei:

     $stmt->bind_result($id, $unique_id, $name, $email, $encrypted_password, $salt, $created_at, $updated_at); $user = $stmt->fetch(); 

    Mas então mudou paira

     $user = $stmt->get_result()->fetch_assoc(); 

    E isso resolveu o problema …

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.