private void joinChannel(final Channel channel) {
    Log.d(TAG, "Joining Channel: " + channel.getFriendlyName());
    channel.join(
        new Constants.StatusListener() {
          @Override
          public void onSuccess() {
            mCurrentChannel = channel;
            Log.d(TAG, "Joined default channel");

            mMembers.clear();
            mMessages.clear();

            MainActivity.this.runOnUiThread(
                new Runnable() {
                  @Override
                  public void run() {
                    setTitle(channel.getFriendlyName());
                    mMessagesAdapter.notifyDataSetChanged();
                  }
                });

            mCurrentChannel.setListener(mChannelListener);
          }

          @Override
          public void onError(ErrorInfo errorInfo) {
            Log.e(TAG, "Error joining channel: " + errorInfo.getErrorText());
          }
        });
  }
 private void joinChannel(String name) {
   for (Channel channel : mMessagingClient.getChannels().getChannels()) {
     if (name.equals(channel.getFriendlyName())) {
       joinChannel(channel);
       break;
     }
   }
 }