コード例 #1
0
  private void requestUpdateData(String uri) throws JSONException {
    for (Book b : adapter.getSelectedBooks()) {
      BorrowedBook bb = (BorrowedBook) b;
      RequestPackaging p = new RequestPackaging();
      p.setMethod("POST"); // Set the HTTP REQUEST method
      p.setUri(uri); // Sets the URI
      JSONArray jar = new JSONArray();
      JSONObject object = new JSONObject();
      object.put("query", "update"); // What kind of query
      object.put("method", "retrieveborrowbook"); // What kind of request
      object.put(
          "id",
          SaveSharedPreference.getID(getActivity())); // Pass the id for the user to the webservice
      object.put("isbn", bb.getIsbn());
      object.put("friendid", bb.getOwner().getId());
      jar.put(object);
      p.setJarParams(jar); // Add the param objects to the JSONArray

      MyTask task = new MyTask();
      task.execute(p);
    }
  }