コード例 #1
0
  public void showUserAsync(String pUserId) {
    try {
      fb.getUser(
          pUserId,
          new AsyncCallbackAdapter() {

            public void onComplete(
                com.blackberry.facebook.model.IObject[] objects, final java.lang.Object state) {
              user = (IUser) objects[0];
              UiApplication.getApplication()
                  .invokeLater(
                      new Runnable() {
                        public void run() {
                          setTitle(
                              new LabelField(
                                  "Hello " + user.getName() + " !",
                                  LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
                          vfm2.deleteAll();
                          vfm2.add(new LabelField("id = " + user.getId()));
                          vfm2.add(new LabelField("name = " + user.getName()));
                          vfm2.add(new LabelField("email = " + user.getEmail()));
                          vfm2.add(new LabelField("birthday = " + user.getBirthdayAsString()));
                          vfm2.add(
                              new LabelField("updated_time = " + user.getUpdatedTimeAsString()));
                        }
                      });
            }

            public void onException(final Exception e, final java.lang.Object state) {
              e.printStackTrace();
              UiApplication.getApplication()
                  .invokeLater(
                      new Runnable() {
                        public void run() {
                          setTitle(
                              new LabelField(
                                  "Error Encountered",
                                  LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
                          vfm2.deleteAll();
                          vfm2.add(new LabelField("Exception: " + e.getMessage()));
                        }
                      });
            }
          },
          null);

    } catch (FacebookException e) {
      e.printStackTrace();
    }

    setTitle(new LabelField("Retrieving...", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
    vfm2.deleteAll();
    vfm2.add(new LabelField("id = ..."));
    vfm2.add(new LabelField("name = ..."));
    vfm2.add(new LabelField("email = ..."));
    vfm2.add(new LabelField("birthday = ..."));
    vfm2.add(new LabelField("updated_time = ..."));
    add(vfm2);
  }
コード例 #2
0
  public void showUserSync(String pUserId) {
    try {
      user = fb.getUser(pUserId);
      setTitle(
          new LabelField(
              "Hello " + user.getName() + " !", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
      vfm2.deleteAll();
      vfm2.add(new LabelField("id = " + user.getId()));
      vfm2.add(new LabelField("name = " + user.getName()));
      vfm2.add(new LabelField("email = " + user.getEmail()));
      vfm2.add(new LabelField("birthday = " + user.getBirthdayAsString()));
      vfm2.add(new LabelField("updated_time = " + user.getUpdatedTimeAsString()));
      add(vfm2);

    } catch (Exception e) {
      e.printStackTrace();
      setTitle(new LabelField("Error Encountered", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
      vfm2.deleteAll();
      vfm2.add(new LabelField("Exception: " + e.getMessage()));
      add(vfm2);

    } finally {
    }
  }