Esempio n. 1
0
    public User checkUser(String username, String password) {
      JSONArray jsonUser = null;
      User u = null;

      Param paramPost = new Param();
      paramPost.addParam("action", Integer.toString(CHECK_USER));
      paramPost.addParam("username", username);
      paramPost.addParam("password", password);

      try {
        jsonUser = request.postData(ip_maestra, paramPost);

        // looping
        if (jsonUser != null) {
          for (int i = 0; i < jsonUser.length(); i++) {
            JSONObject m = jsonUser.getJSONObject(i);
            u = new User();
            u.set_id(m.getInt("_id"));
            u.setUsername(m.getString("username"));
            u.setPassword(m.getString("password"));
            u.setFirst_name(m.getString("first_name"));
            u.setFirst_name(m.getString("last_name"));
            u.setEmail(m.getString("email"));
            u.setStatus(m.getInt("status"));
            u.setProfile_id(m.getInt("profile_id"));
            u.setProfile_description(m.getString("description"));
            u.setCreated_at(m.getString("created_at"));
            u.setUpdated_at(m.getString("updated_at"));
            Log.d("outPut", "user username: "******"username"));
          }
        }
      } catch (JSONException e) {
        e.printStackTrace();
      }

      return u;
    }