public void request() {

    final ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

    JSONObject json =
        JSONfunctions.getJSONfromURL(
            "http://api.ticketline.co.uk//recommendation?method=getHighlights&limit=8&api-key=NGNkZGRhYjkzY2Z&on-sale=true");

    try {

      earthquakes = json.getJSONArray("categories");

      for (int i = 0; i < earthquakes.length(); i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        JSONObject e = earthquakes.getJSONObject(i);

        map.put("id", String.valueOf(i));
        map.put("name", e.getString("name"));
        map.put("magnitude", e.getString("id"));
        mylist.add(map);

        idsArray.add(e.getString("id"));
        namesArray.add(e.getString("name"));
        slugsArray.add(e.getString("slug"));
        captionArray.add(e.getString("caption"));
        Images = "{\"images\":" + e.getString("Images") + "}";

        // Log.i("Base Url",e.getString("image_base_url"));
        url = e.getString("image_base_url");
        imageName = e.getString("image_default");

        imageUrl.add(e.getString("image_base_url"));
        imageNames.add(e.getString("image_default"));
        // Log.i("image jason",Images);
        recomendedArray.add(url + imageName);
        // get the images
        JSONObject imageArray = new JSONObject(Images);
        JSONArray img = imageArray.getJSONArray("images");
        for (int a = 0; a < img.length(); a++) {
          JSONObject ee = img.getJSONObject(a);

          try {
            Log.i("Full url", url + ee.getString("filename"));

          } catch (Exception e1) {
            // do something
          }
        }
      }
    } catch (JSONException e) {
      Log.e("log_tag", "Error parsing data " + e.toString());
    }

    for (int i = 0; i < recomendedArray.size(); i++) {
      Log.i("From Array", i + " " + recomendedArray.get(i));
    }
  }
示例#2
0
    @Override
    protected Boolean doInBackground(String... params) {
      // TODO: attempt authentication against a network service.

      List<NameValuePair> param = new ArrayList<NameValuePair>();
      param.add(new BasicNameValuePair("username", mEmail));
      param.add(new BasicNameValuePair("password", mPassword));
      String s;
      s = JSONfunctions.getJSONfromURL("http://apptesting.comuv.com/login.php", param);

      for (String credential : DUMMY_CREDENTIALS) {
        String[] pieces = credential.split(":");
        if (pieces[0].equals(mEmail)) {
          // Account exists, return true if the password matches.
          return pieces[1].equals(mPassword);
        }
      }

      // TODO: register the new account here.
      return true;
    }