资讯专栏INFORMATION COLUMN

集分享/支付/授权的社会化组件,交流一下

Lin_YT / 3275人阅读

摘要:百度超过千亿的中文网页数据库,可以瞬间找到相关的搜索结果。小程序类型正式版,测试版,体验版小程序小程序页面地址自定义图标需要集成图片库

SocialComponent

社会化组件

集成步骤

1、依赖library库

2、给Project的build.gradle文件添加如下代码:

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://dl.bintray.com/thelasterstar/maven/" }
    }
}

3、配制AndroidManifest.xml,添加如下代码:


    
        
            

            
        
    
    

    
    
    
    
    
    
        
            

            
            

            
        
    
    
    

4、在自己的包名下添加wxapi包及里面的所有java文件

5、在自定义的Application中初始化

//初始化数据
SocialHelper.get().setQqAppId("1107009250")
        .setWxAppId("wx2847b18acb41e535")
        .setWxAppSecret("78f713b76c61a38242e63ccdb3a96d68")
        .setWbAppId("2214687859")
        .setWbRedirectUrl("https://github.com/fengqingxiuyi");
功能详情

各功能使用详情,请参考MainActivity.java

例如:

/**
 * 分享
 */
public void jump2Share(View view) {
    ShareDataBean shareDataBean = new ShareDataBean();
    HashMap shareTypeList = new HashMap<>();
    shareTypeList.put(ISocialType.SOCIAL_WX_SESSION, WXShareHelper.TYPE_WEB);
    shareTypeList.put(ISocialType.SOCIAL_WX_TIMELINE, WXShareHelper.TYPE_WEB);
    shareTypeList.put(ISocialType.SOCIAL_WX_MINIPROGRAM, WXShareHelper.TYPE_MINIPROGRAM);
    shareTypeList.put(ISocialType.SOCIAL_QQ, QQShareHelper.TYPE_IMAGE_TEXT);
    shareTypeList.put(ISocialType.SOCIAL_WB, WBShareHelper.TYPE_TEXT);
    shareDataBean.shareType = shareTypeList;
    shareDataBean.shareTitle = "百度一下,你就知道";
    shareDataBean.shareDesc = "全球最大的中文搜索引擎、致力于让网民更便捷地获取信息,找到所求。百度超过千亿的中文网页数据库,可以瞬间找到相关的搜索结果。";
    shareDataBean.shareImage = "https://www.baidu.com/img/bd_logo1.png";
    shareDataBean.shareUrl = "https://www.baidu.com/";
    shareDataBean.shareMiniType = 0; //小程序类型 - 正式版:0,测试版:1,体验版:2
    shareDataBean.shareMiniAppId = "gh_64c734bc4b8d"; //小程序AppId
    shareDataBean.shareMiniPage = "pages/fitting-room/index"; //小程序页面地址

    ArrayList socialTypeBeans = new ArrayList<>();
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_WX_SESSION));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_WX_TIMELINE));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_SMS));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_COPY));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_REFRESH));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_CUSTOM, "https://img.ezprice.com.tw/is/c.rimg.com.tw/s1/4/7e/29/21628111029801_843_s.jpg", "自定义图标需要集成图片库"));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_QQ));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_WB));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_WX_MINIPROGRAM));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_ALIPAY));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_COLLECTION));
    socialTypeBeans.add(new SocialTypeBean(ISocialType.SOCIAL_SHOW_ALL));

    SocialHelper.get().share(this, socialTypeBeans, shareDataBean, new IShareCallback() {
        @Override
        public void onSuccess(int socialType, String msg) {
            Toast.makeText(MainActivity.this, "MainActivity onSuccess, socialType = " + socialType +", msg = " + msg, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(int socialType, String msg) {
            Toast.makeText(MainActivity.this, "MainActivity onError, socialType = " + socialType +", msg = " + msg, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onCancel(int socialType) {
            Toast.makeText(MainActivity.this, "MainActivity onCancel, socialType = " + socialType, Toast.LENGTH_SHORT).show();
        }
    });
}

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/76751.html

相关文章

  • 这次要是讲不明白Spring Cloud核心组件,那我就白编这故事了

    摘要:我不听,我就是这么命名。任何服务启动以后,都会把自己注册到的注册表中当服务死亡的时候,也会通知。服务拿到结果后,会把结果缓存在本地的注册表里。根据负载均衡策略,从注册表中选择一个真正的实例地址。 原创:小姐姐味道(微信公众号ID:xjjdog),欢迎分享,转载请保留出处。 这几天可真是热啊,泡个海澡是再好不过了。玩的正起劲,突然脚底绊上一股暗流,然后我就一直在水里旋转旋转旋转...终于...

    stdying 评论0 收藏0

发表评论

0条评论

Lin_YT

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<