
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);
@Overridepublic boolean onCapsuleButtonCloseClick(IMiniAppContext miniAppContext,DialogInterface.OnClickListener onCloseClickedListener) {Log.e("TAG","onCapsuleButtonCloseClick"+miniAppContext.getMiniAppInfo());//handle close mini app eventreturn true;}

/*** 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);
@Overridepublic boolean onCapsuleButtonMoreClick(IMiniAppContext miniAppContext) {// Pop up the custom More panelreturn true;}

/*** 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);
@Overridepublic 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 eventsitem2.onClickListener = new MoreItem.MoreItemClickListener() {@Overridepublic void onClick(IMiniAppContext context, MoreItem item) {// Handle tap event}};// Adjust the order as neededbuilder.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);}
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback