private Request createRequest(
      Location location,
      int radiusInMeters,
      int resultsLimit,
      String searchText,
      Set<String> extraFields,
      Session session) {
    Request request =
        Request.newPlacesSearchRequest(
            session, location, radiusInMeters, resultsLimit, searchText, null);

    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[] {ID, NAME, LOCATION, CATEGORY, WERE_HERE_COUNT};
    fields.addAll(Arrays.asList(requiredFields));

    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
      fields.add(pictureField);
    }

    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);

    return request;
  }
示例#2
0
  private void Poimg(Bitmap b) {

    Session session = Session.getActiveSession();
    if (session != null) {

      // Part 1: create callback to get URL of uploaded photo
      Request.Callback uploadPhotoRequestCallback =
          new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
              // safety check
              if (isFinishing()) {
                return;
              }
              if (response.getError() != null) { // [IF Failed Posting]
                Log.d("", "photo upload problem. Error=" + response.getError());
                System.out.println(response.getError());
              } //  [ENDIF Failed Posting]
              Object graphResponse = response.getGraphObject().getProperty("id");
              if (graphResponse == null
                  || !(graphResponse instanceof String)
                  || TextUtils.isEmpty((String) graphResponse)) { // [IF Failed upload/no results]
                Log.d("", "failed photo upload/no response");
              } else { // [ELSEIF successful upload]
                fbPhotoAddress = "https://www.facebook.com/photo.php?fbid=" + graphResponse;

                System.out.println(fbPhotoAddress + "/////");
              } // [ENDIF successful posting or not]
            } // [END onCompleted]
          };

      // Part 2: upload the photo
      Request request = Request.newUploadPhotoRequest(session, b, uploadPhotoRequestCallback);
      Bundle bundle = request.getParameters();
      bundle.putString(
          "message",
          "受測者:"
              + UserName
              + "\n拍攝日期:"
              + Data[0]
              + "\n酒測值:"
              + Data[1]
              + "/L"
              + "\n位置:"
              + returnAddress);
      request.setParameters(bundle);
      /*紫陽科技酒測即時群組*/
      request.setGraphPath("615097428532040/photos");
      /*
       * 	測試群組
       * request.setGraphPath("612077312161579/photos");
       */
      /*	個人塗鴉牆
       * request.setGraphPath("me/photos");
       */
      request.executeAsync();
    }
  }