private static final String SHARE_TWITTER = "twitter";/*** 返回自定义分享数据Map* 调用环境:子进程** key:与getMoreItems方法中添加的MoreItem.id一致* value:与getMoreItems方法中添加的MoreItem.shareKey一致* @return*/@Overridepublic Map<String, Integer> getCustomShare(){Map<String, Integer> objects = new HashMap<>();objects.put(SHARE_TWITTER, ShareProxyImpl.OTHER_MORE_ITEM_2);return objects;}/*** 返回胶囊更多面板的按钮,扩展按钮的ID需要设置为[100, 200]这个区间中的值,否则,添加无效* 调用环境:子进程** @param miniAppContext 小程序运行环境(小程序进程,非主进程)* @param builder* @return*/@Overridepublic ArrayList<MoreItem> getMoreItems(IMiniAppContext miniAppContext, MoreItemList.Builder builder) {MoreItem item2 = new MoreItem();item2.id = ShareProxyImpl.OTHER_MORE_ITEM_2;item2.text = getString(miniAppContext,R.string.applet_mini_proxy_impl_other2);item2.shareKey = SHARE_TWITTER;//自定义分享的key,必须设置且唯一,与小程序端调用控制设置时会使用到item2.drawable = R.mipmap.mini_demo_about;builder.addMoreItem(item2)return builder.build();}
/*** 返回胶囊更多面板按钮单击监听器** @return*/@Overridepublic OnMoreItemSelectedListener getMoreItemSelectedListener() {return new DemoMoreItemSelectedListener();}public class DemoMoreItemSelectedListener extends DefaultMoreItemSelectedListener {public static final int CLOSE_MINI_APP = 150;@Overridepublic void onMoreItemSelected(IMiniAppContext miniAppContext, int moreItemId) {//处理开发者自定义点击事件(自定义分享事件除外)switch (moreItemId) {case CLOSE_MINI_APP:close(miniAppContext);return;case OTHER_MORE_ITEM_1:miniAppContext.getAttachedActivity().runOnUiThread(new Runnable() {@Overridepublic void run() {Toast.makeText(miniAppContext.getAttachedActivity(), "custom menu click", Toast.LENGTH_SHORT).show();}});return;}//处理内置分享和开发者自定义分享,例如:微博、twitter等super.onMoreItemSelected(miniAppContext, moreItemId);}}
@ProxyService(proxy = ShareProxy.class)public class ShareProxyImpl extends BaseShareProxy {/*** 分享** @param shareData 分享数据*/@Overridepublic void share(Activity activity, ShareData shareData) {//todo share}}
本页内容是否解决了您的问题?