AndroidAndroid V4 Channel Groups API Reference for Realtime Apps

Go to Access Manager


Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function adds a channel to a channel group.
Adding Channels is accomplished by using the following method(s) in the Android V4 SDK:
 

200 channels can be added to the channel group per API call.

  1. ParameterTypeRequiredDescription
    channelGroupStringYesThe channelGroup to add the channels to.
    channelsArrayYesThe channel to add to the channel group.
    asyncPNCallbackYesPNCallback of type PNChannelGroupsAddChannelResult
pubnub.addChannelsToChannelGroup()
    .channelGroup("cg1")
    .channels(Arrays.asList("ch1", "ch2", "ch3"))
    .async(new PNCallback<PNChannelGroupsAddChannelResult>() {
        @Override
        public void onResponse(PNChannelGroupsAddChannelResult result, PNStatus status) {

        }
    });
The addChannelsToChannelGroup() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError().
{
    "service" : "channel-registry",
    "status"  : 200,
    "error"   : false,
    "message" : "OK"
}
Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function lists all the channels of the channel group.
Listing Channels is accomplished by using the following method(s) in the Android V4 SDK:
  1. ParameterTypeRequiredDescription
    channelGroupStringYesChannel group to fetch the channels.
    asyncPNCallbackYesPNCallback of type PNChannelGroupsAllChannelsResult.
pubnub.listChannelsForChannelGroup()
    .channelGroup("cg1")
    .async(new PNCallback<PNChannelGroupsAllChannelsResult>() {
        @Override
        public void onResponse(PNChannelGroupsAllChannelsResult result, PNStatus status) {

        }
    });
The listChannelsForChannelGroup() operation returns a PNChannelGroupsAllChannelsResult which contains the following operations:
MethodTypeDescription
getChannels()List<String>List of channels of a channel group.
Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channels from the channel group.
Removing Channels is accomplished by using the following method(s) in the Android V4 SDK:
  1. ParameterTypeRequiredDescription
    channelsArrayYesThe channels to remove from the channel group.
    channelGroup StringYesSpecifies channelGroup to remove the channels from.
    asyncPNCallbackOptionalPNCallback of type PNChannelGroupsRemoveChannelResult.
pubnub.removeChannelsFromChannelGroup()
    .channelGroup("family")
    .channels(Arrays.asList("son"))
    .async(new PNCallback<PNChannelGroupsRemoveChannelResult>() {
        @Override
        public void onResponse(PNChannelGroupsRemoveChannelResult result, PNStatus status) {
 
        }
    });
The removeChannelsFromChannelGroup() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError().
{
	"status" : 200,
	"message" : "OK",
	"service" : "channel-registry",
	"error" : False
}
Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channel group.
Deleting Channel Group is accomplished by using the following method(s) in the Android V4 SDK:
  1. ParameterTypeRequiredDescription
    channelGroup StringYesSpecifies channelGroup to remove.
    asyncPNCallbackOptionalPNCallback of type PNChannelGroupsDeleteGroupResult.
pubnub.deleteChannelGroup()
	.channelGroup("family")
	.async(new PNCallback<PNChannelGroupsDeleteGroupResult>() {
		@Override
		public void onResponse(PNChannelGroupsDeleteGroupResult result, PNStatus status) {

		}
	});
The deleteChannelGroup() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError().
{
	"status" : 200,
	"message" : "OK",
	"service" : "channel-registry",
	"error" : False
}

Go to Storage and Playback