public void testEntityMetaDataWithUrl() throws Exception {

    final String entityKey = "testEntityMetaDataWithUrl" + Math.random();

    Entity entity = Entity.newInstance(entityKey, "testAddEntity");

    String url = "http://www.getsocialize.com";

    JSONObject metaData = new JSONObject();
    metaData.put("url", url);

    String jsonString = metaData.toString();

    entity.setMetaData(jsonString);

    final CountDownLatch latch = new CountDownLatch(1);

    // Force no config
    ConfigUtils.getConfig(getContext())
        .setProperty(SocializeConfig.SOCIALIZE_REQUIRE_AUTH, "false");

    EntityUtils.saveEntity(
        TestUtils.getActivity(this),
        entity,
        new EntityAddListener() {

          @Override
          public void onError(SocializeException error) {
            error.printStackTrace();
            addResult(0, error);
            latch.countDown();
          }

          @Override
          public void onCreate(Entity entity) {
            addResult(0, entity);
            latch.countDown();
          }
        });

    latch.await(20, TimeUnit.SECONDS);

    Object result = getResult(0);

    assertNotNull(result);
    assertTrue("Result is not a entity object", (result instanceof Entity));

    Entity entityAfter = (Entity) result;

    String metaDataAfter = entityAfter.getMetaData();

    assertNotNull(metaDataAfter);

    JSONObject json = new JSONObject(metaDataAfter);
    String urlAfter = json.getString("url");

    assertEquals(url, urlAfter);
  }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {

    if (position <= 1) {

      String entity = null;

      switch (position) {
        case 0:
          entity = "http://getsocialize.com";
          break;
      }

      CommentUtils.showCommentView(
          this,
          Entity.newInstance(entity, "Socialize"),
          new OnCommentViewActionListener() {

            @Override
            public void onError(SocializeException error) {
              error.printStackTrace();
            }

            @Override
            public void onRender(CommentListView view) {}

            @Override
            public void onReload(CommentListView view) {}

            @Override
            public void onPostComment(Comment comment) {}

            @Override
            public void onCreate(CommentListView view) {}

            @Override
            public void onCommentList(
                CommentListView view, List<Comment> comments, int start, int end) {}

            @Override
            public void onBeforeSetComment(Comment comment, CommentListItem item) {}

            @Override
            public void onAfterSetComment(Comment comment, CommentListItem item) {}
          });
    } else {
      Class<?> activityClass = activities[position - 1];
      if (activityClass != null) {
        Intent intent = new Intent(this, activityClass);
        startActivity(intent);
      }
    }
  }
  // begin-snippet-0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Define/obtain your entity
    Entity entity = Entity.newInstance("http://getsocialize.com", "Socialize");

    // Get a reference to the button you want to transform
    // This can be any type of CompoundButton (CheckBox, RadioButton, Switch, ToggleButton)

    CheckBox btnCustomCheckBoxLike = (CheckBox) findViewById(R.id.btnCustomCheckBoxLike);

    // Make the button a socialize like button!
    LikeUtils.makeLikeButton(
        this,
        btnCustomCheckBoxLike,
        entity,
        new LikeButtonListener() {

          @Override
          public void onClick(CompoundButton button) {
            // You can use this callback to set any loading text or display a progress dialog
            button.setText("--");
          }

          @Override
          public void onCheckedChanged(CompoundButton button, boolean isChecked) {
            // The like was posted successfully, change the button to reflect the change
            if (isChecked) {
              button.setText("Unlike");
            } else {
              button.setText("Like");
            }
          }

          @Override
          public void onError(CompoundButton button, Exception error) {
            // An error occurred posting the like, we need to return the button to its original
            // state
            Log.e("Socialize", "Error on like button", error);
            if (button.isChecked()) {
              button.setText("Unlike");
            } else {
              button.setText("Like");
            }
          }
        });
  }
  // end-snippet-0
  void reload() {
    // begin-snippet-1

    // The in the Activity which renders the ActionBar
    Entity entity = Entity.newInstance("http://getsocialize.com", "Socialize");

    // Setup a listener to retain a reference
    MyActionBarListener listener = new MyActionBarListener();

    // Use the listener when you show the action bar
    // The "this" argument refers to the current Activity
    ActionBarUtils.showActionBar(this, R.layout.actionbar, entity, null, listener);

    // Later (After the action bar has loaded!), you can reference the view to refresh
    ActionBarView view = listener.getActionBarView();

    if (view != null) {
      Entity newEntity = new Entity(); // This would be your new entity
      view.setEntity(newEntity);
      view.refresh();
    }

    // end-snippet-1
  }
  public void testAddEntity() throws Exception {
    final String entityKey = "testAddEntity" + Math.random();
    Entity entity = Entity.newInstance(entityKey, "testAddEntity");

    final CountDownLatch latch = new CountDownLatch(1);

    // Force no config
    ConfigUtils.getConfig(getContext())
        .setProperty(SocializeConfig.SOCIALIZE_REQUIRE_AUTH, "false");

    EntityUtils.saveEntity(
        TestUtils.getActivity(this),
        entity,
        new EntityAddListener() {

          @Override
          public void onError(SocializeException error) {
            error.printStackTrace();
            addResult(0, error);
            latch.countDown();
          }

          @Override
          public void onCreate(Entity entity) {
            addResult(0, entity);
            latch.countDown();
          }
        });

    latch.await(20, TimeUnit.SECONDS);

    Object result = getResult(0);

    assertNotNull(result);
    assertTrue("Result is not a entity object", (result instanceof Entity));

    Entity entityAfter = (Entity) result;
    assertTrue("Entity ID is not greater than 0", entityAfter.getId() > 0);

    // Now use the normal UI to retrieve the entity
    clearResults();
    final CountDownLatch latch2 = new CountDownLatch(1);

    EntityUtils.getEntity(
        TestUtils.getActivity(this),
        entityAfter.getId(),
        new EntityGetListener() {

          @Override
          public void onGet(Entity entity) {
            addResult(0, entity);
            latch2.countDown();
          }

          @Override
          public void onError(SocializeException error) {
            error.printStackTrace();
            latch2.countDown();
          }
        });

    latch2.await(20, TimeUnit.SECONDS);

    Entity after = getResult(0);

    assertNotNull(after);
    assertEquals(entityAfter.getId(), after.getId());
    assertEquals(entityAfter.getKey(), after.getKey());
  }