tencent cloud

Tencent Cloud Super App as a Service

Capsule Button Event Listener

Download
Focus Mode
Font Size
Last updated: 2026-04-30 15:44:21

Close Button

Customizing the close event listener for the capsule button allows the superapp to receive the corresponding callback when the close button is tapped.
Close button in the image:

API description:The return value of the onCapsuleButtonCloseClick method indicates whether a custom close button listener is implemented. A return value of true indicates customization, while false (the default value) indicates the use of the default listener.
/**
* Tap event for the capsule button's close option
* Calling environment: Subprocess
*
* @param miniAppContext - Mini program runtime environment (mini program process, not main process)
* @param onCloseClickedListener - Callback when the mini program is closed
* @return - Returns false if this API is not supported
*/
public abstract boolean onCapsuleButtonCloseClick(IMiniAppContext miniAppContext,
DialogInterface.OnClickListener onCloseClickedListener);
Example:
@Override
public boolean onCapsuleButtonCloseClick(IMiniAppContext miniAppContext,
DialogInterface.OnClickListener onCloseClickedListener) {
Log.e("TAG","onCapsuleButtonCloseClick"+miniAppContext.getMiniAppInfo());
//handle close mini app event
return true;
}

More Button

Customizing the event listener for the More button allows the superapp to capture the corresponding callback event when the More button is tapped.
More button in the image:



API Description: The onCapsuleButtonMoreClick method's return value indicates whether the More button listener is customized. A return value of true means it is customized, while false (the default value) means the default listener is used.
/**
* Tap event for the More options on the capsule button
*
* @param miniAppContext - Mini program runtime environment
* @return - Returns false if this API is not supported
*/
public abstract boolean onCapsuleButtonMoreClick(IMiniAppContext miniAppContext);
Example:
@Override
public boolean onCapsuleButtonMoreClick(IMiniAppContext miniAppContext) {
// Pop up the custom More panel
return true;
}

Extension Button List for the More Menu

When a user triggers the tap event for the More button, a list of optional extension buttons will pop up, as illustrated in the default list below:

By overriding the getMoreItems method in the MiniAppProxy class, you can customize the list of extension buttons for the More menu.
API description:
The getMoreItems method's return value represents the customized list of extension buttons.
Parameters MoreItemList.Builder is used to add extension buttons, and the display order of the buttons will match the order in which they are added.
MoreItem’s ID property is used to distinguish between buttons and must be unique.
/**
* Returns the buttons for the capsule's More panel. The IDs for extension buttons must be set within the range of [100, 200]; otherwise, the addition will be invalid.
* Calling environment: Subprocess
*
* @param builder
* @return
*/
public abstract ArrayList<MoreItem> getMoreItems(MoreItemList.Builder builder);

Warning:
The IDs for extension buttons must be set within the range of [100, 200]; otherwise, the addition will be invalid.
Example:
@Override
public ArrayList<MoreItem> getMoreItems(IMiniAppContext miniAppContext, MoreItemList.Builder builder) {
MoreItem item1 = new MoreItem();
// Set the menu ID (required), the ID for extension buttons must be within the range of [100, 200]; otherwise, the addition will be invalid.
item1.id = ShareProxyImpl.OTHER_MORE_ITEM_1;
// Set the menu title (optional)
item1.text = getString(miniAppContext, R.string.applet_mini_proxy_impl_other1);
// Set the menu icon (optional)
item1.drawable = R.mipmap.mini_demo_about;
// Set the visual accessibility description (optional). Defaults to the menu title.
item2.contentDescription = "Visual accessibility description for the menu";
// Listen for tap events
item2.onClickListener = new MoreItem.MoreItemClickListener() {
@Override
public void onClick(IMiniAppContext context, MoreItem item) {
// Handle tap event
}
};

// Adjust the order as needed
builder.addMoreItem(item1)
// Add built-in menu items as needed
.addRestart(getString(miniAppContext, R.string.applet_mini_proxy_impl_restart),
R.mipmap.mini_demo_restart_miniapp)
// Add built-in menu items as needed
.addAbout(getString(miniAppContext, R.string.applet_mini_proxy_impl_about),
R.mipmap.mini_demo_about)
// Add built-in menu items as needed
.addSetting(getString(miniAppContext, R.string.mini_sdk_more_item_setting_0),
R.drawable.mini_sdk_setting,
// Set the visual accessibility description (optional). Defaults to the menu title.
"Mini program settings");
return builder.build();
}

private String getString(IMiniAppContext miniAppContext, int id) {
return miniAppContext.getContext().getString(id);
}

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback