Android 集成微信、QQ、微博、支付宝、银联、华为、OPPO

效果图

Android 集成微信、QQ、微博、支付宝、银联、华为、OPPO_第1张图片

WechatIMG26.png

源码

版本

  1. 华为: 2.6.3.301
  2. QQ: 3.3.3 (6008)
  3. 微博: 4.3.9
  4. 微信: 5.4.0
  5. 银联: 3.4.1
  6. 支付宝: 15.6.4
  7. OPPO:2.0.0

集成

  1. 添加仓库地址

    maven { url "https://dl.bintray.com/thelasterstar/maven/" }     // 微博 aar
    maven { url 'http://developer.huawei.com/repo/' }               // 华为仓库
    maven { url 'https://dl.bintray.com/wenjie/maven' }
    
  2. 根据要集成的第三方库添加依赖

    api 'com.enowr.android:Auth:0.0.7'
    api 'com.enowr.android:AuthHW:0.0.7'
    api 'com.enowr.android:AuthQQ:0.0.7'
    api 'com.enowr.android:AuthWB:0.0.7'
    api 'com.enowr.android:AuthWX:0.0.7'
    api 'com.enowr.android:AuthYL:0.0.7'
    api 'com.enowr.android:AuthZFB:0.0.7'
    api 'com.enowr.android:AuthOPPO:0.0.7'
    
  3. Manifest

    
        
                                          
                            
                               
                                  
                                   
                          
    
        
        
        
        
        
        
        
        
        
        
        
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
        
            
            
            
            
            
            
            
            
            
            
            
            
            
        
        
            
            
            
                
                    
                    
                    
                    
                
            
        
        
            
            
            
            
            
            
            
                
                    
                    
                    
                    
                
            
            
            
                                    
                
            
    
    
  4. 混淆

    # Auth
    -keep class com.enowr.** {*;}
    
    
    # 华为
    -ignorewarning
    -keepattributes *Annotation*
    -keepattributes Exceptions
    -keepattributes InnerClasses
    -keepattributes Signature
    -keepattributes SourceFile,LineNumberTable
    -keep class com.hianalytics.android.**{*;}
    -keep class com.huawei.updatesdk.**{*;}
    -keep class com.huawei.hms.**{*;}        
    -keep class com.huawei.android.hms.agent.**{*;}
    
    
    # QQ
    -keep class com.tencent.open.TDialog$*
    -keep class com.tencent.open.TDialog$* {*;}
    -keep class com.tencent.open.PKDialog
    -keep class com.tencent.open.PKDialog {*;}
    -keep class com.tencent.open.PKDialog$*
    -keep class com.tencent.open.PKDialog$* {*;}
    
    
    # 微博
    -keep class com.sina.weibo.sdk.** {*;}
    
    
    # 微信
    -keep class com.tencent.mm.opensdk.** {*;}
    -keep class com.tencent.wxop.** {*;}
    -keep class com.tencent.mm.sdk.** {*;}
    
    
    # 银联
    -keep  public class com.unionpay.uppay.net.HttpConnection {public ;}
    -keep  public class com.unionpay.uppay.net.HttpParameters {public ;}
    -keep  public class com.unionpay.uppay.model.BankCardInfo {public ;}
    -keep  public class com.unionpay.uppay.model.PAAInfo {public ;}
    -keep  public class com.unionpay.uppay.model.ResponseInfo {public ;}
    -keep  public class com.unionpay.uppay.model.PurchaseInfo {public ;}
    -keep  public class com.unionpay.uppay.util.DeviceInfo {public ;}
    -keep  public class com.unionpay.uppay.util.PayEngine {
        public ;
        native ;
    }
    -keep  public class com.unionpay.utils.UPUtils {native ;}
    
    
    # 支付宝
    -keep class com.alipay.android.app.IAlixPay{*;}
    -keep class com.alipay.android.app.IAlixPay$Stub{*;}
    -keep class com.alipay.android.app.IRemoteServiceCallback{*;}
    -keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
    -keep class com.alipay.sdk.app.PayTask{ public *;}
    -keep class com.alipay.sdk.app.AuthTask{ public *;}
    -keep class com.alipay.sdk.app.H5PayCallback {
        ;
        ;
    }
    -keep class com.alipay.android.phone.mrpc.core.** { *; }
    -keep class com.alipay.apmobilesecuritysdk.** { *; }
    -keep class com.alipay.mobile.framework.service.annotation.** { *; }
    -keep class com.alipay.mobilesecuritysdk.face.** { *; }
    -keep class com.alipay.tscenter.biz.rpc.** { *; }
    -keep class org.json.alipay.** { *; }
    -keep class com.alipay.tscenter.** { *; }
    -keep class com.ta.utdid2.** { *;}
    -keep class com.ut.device.** { *;}
    # SDK 包可能不包含 utdid
    -dontwarn com.ta.utdid2.**
    -dontwarn com.ut.device.**
    # SDK 包可能不包含 securitysdk
    -dontwarn com.alipay.mobilesecuritysdk.**
    
    # OPPO
    -keep class com.nearme.** {*;}
    
  5. 初始化

     Auth.init()
            .setHWAppID("")
            .setHWKey("")
            .setHWMerchantID("")
            .setQQAppID("")
            .setWXAppID("")
            .setWXSecret("")
            .setWBAppKey("")
            .setWBRedirectUrl("")
            .setWBScope("")
            .setOPPOAppSecret("secret")
            .build();
    
    // 如果使用华为支付功能, 还需要在 MainActivity 里初始化华为
    Auth.withHW(context).initHW(activity);
    
    // OPPO 要求使用OPPO 自带的退出功能
    Auth.withOPPO(context).exit(activity);
    
    // 使用微信相关功能
    // 包名相应目录下新建一个wxapi目录,并在该wxapi目录下新增两个WXPayEntryActivity、WXEntryActivity类,继承自AuthActivity
    

使用

    public void hwLogin() {
        Auth.withHW(this)
                .loginForceLogin(false)  // 当force为false时,错误码为2001、2002时,会再次以参数为ture尝试调用一次
                .login(mCallback);
    }

    public void hwPay() {
        Auth.withHW(this)
                .payAmount("")
                .payApplicationId("")
                .payChannel(1)
                .payCountry("")
                .payCurrency("")
                .payExtReserved("")
                .payMerchantId("")
                .payMerchantName("")
                .payProductDesc("")
                .payProductName("")
                .payPublicKey("")
                .payRequestId("")
                .payServiceCatalog("")
                .paySign("")
                .payUrl("")
                .payVersion("")
                .pay(mCallback);
    }

    public void hwRouse() {
        Auth.withHW(this)
                .rouseAmount("")
                .rouseApplicationId("")
                .rouseChannel(1)
                .rouseCountry("")
                .rouseCurrency("")
                .rouseExtReserved("")
                .rouseMerchantId("")
                .rouseMerchantName("")
                .rouseProductDesc("")
                .rouseProductName("")
                .rousePublicKey("")
                .rouseRequestId("")
                .rouseServiceCatalog("")
                .rouseSign("")
                .rouseUrl("")
                .rouseVersion("")
                .rouseTradeType("")
                .rouse(mCallback);
    }
    
    public void oppoPay() {
        Auth.withOPPO(this)
                .payAmount(1)
                .payAttach("attach")
                .payOrderId(String.valueOf(System.currentTimeMillis()))
                .payProductName("test")
                .payProductDesc("test")
                .payCallbackUrl("")
                .payUseCachedChannel(false)
                .pay(mCallback);
    }

    public void qqLogin() {
        Auth.withQQ(this)
                .loginQrcode(true)
                .login(mCallback);
    }

    public void qqShareText() {
        Auth.withQQ(this)
                .shareTextArk("")
                .shareTextImage("")
                .shareTextName("")
                .shareTextQzoneHide(true)
                .shareTextSummary("")
                .shareTextTargetUrl("")
                .shareTextTitle("")
                .shareText(mCallback);
    }

    public void qqShareImage() {
        Auth.withQQ(this)
                .shareImageArk("")
                .shareImagePath("")
                .shareImageName("")
                .shareImageQzoneHide(true)
                .shareImage(mCallback);
    }

    public void qqShareMusic() {
        Auth.withQQ(this)
                .shareMusicImageUrl("")
                .shareMusicSummary("")
                .shareMusicArk("")
                .shareMusicName("")
                .shareMusicQzoneHide(true)
                .shareMusicTargetUrl("")
                .shareMusicTitle("")
                .shareMusicUrl("")
                .shareMusic(mCallback);
    }

    public void qqShareVideo() {
        Auth.withQQ(this)
                .shareVideoPath("")
                .shareVideoBack("")
                .shareVideoImageList(null)
                .shareVideoScene("")
                .shareVideoSummary("")
                .shareVideo(mCallback);
    }

    public void qqShareApp() {
        Auth.withQQ(this)
                .shareAppName("")
                .shareAppImageUrl("")
                .shareAppSummary("")
                .shareAppTitle("")
                .shareAppArk("")
                .shareAppQzoneHide(true)
                .shareApp(mCallback);
    }

    public void qqShareQzone() {
        Auth.withQQ(this)
                .shareToQzoneImageList(null)
                .shareToQzoneSummary("")
                .shareToQzoneTargetUrl("")
                .shareToQzoneTitle("")
                .shareToQzone(mCallback);
    }

    public void qqShareMood() {
        Auth.withQQ(this)
                .shareToMoodBack("")
                .shareToMoodImageList(null)
                .shareToMoodScene("")
                .shareToMoodSummary("")
                .shareToMoodVideoPath("")
                .shareToMood(mCallback);
    }

    public void wbLogin() {
        Auth.withWB(this)
                .login(mCallback);
    }

    public void wbShareText() {
        Auth.withWB(this)
                .shareTextContent("")
                .shareTextSummary("")
                .shareTextTitle("")
                .shareTextUrl("")
                .shareText(mCallback);
    }

    public void wbShareImage() {
        Auth.withWB(this)
                .shareImageBitmap(null)
                .shareImageContent("")
                .shareImage(mCallback);
    }

    public void wbShareMultiImage() {
        Auth.withWB(this)
                .shareMultiImageContent("")
                .shareMultiImageUriList(null)
                .shareMultiImage(mCallback);
    }

    public void wbShareLink() {
        Auth.withWB(this)
                .shareLinkContent("")
                .shareLinkSummary("")
                .shareLinkThumbImage(null)
                .shareLinkTitle("")
                .shareLinkUrl("")
                .shareLink(mCallback);
    }

    public void wbShareVideo() {
        Auth.withWB(this)
                .shareVideoPath("")
                .shareVideoContent("")
                .shareVideoSummary("")
                .shareVideoTitle("")
                .shareVideo(mCallback);
    }

    public void wbShareToStory() {
        Auth.withWB(this)
                .shareToStoryImagePath("")
                .shareToStoryVideoPath("")
                .shareToStory(mCallback);
    }

    public void wxLogin() {
        Auth.withWX(this)
                .login(mCallback);
    }

    public void wxPay() {
        Auth.withWX(this)
                .payNonceStr("")
                .payPackageValue("")
                .payPartnerId("")
                .payPrepayId("")
                .paySign("")
                .payTimestamp("")
                .pay(mCallback);
    }

    public void wxRouse() {
        Auth.withWX(this)
                .rouseUrl("")
                .rouse(mCallback);
    }

    public void wxShareText() {
        Auth.withWX(this)
                .shareTextSummary("")
                .shareTextContent("")
                .shareTextThumbData(null)
                .shareTextTitle("")
                .shareText(mCallback);
    }

    public void wxShareImage() {
        Auth.withWX(this)
                .shareImageBitmap(null)
                .shareImageSummary("")
                .shareImageThumbData(null)
                .shareImageTitle("")
                .shareImage(mCallback);
    }

    public void wxShareLink() {
        Auth.withWX(this)
                .shareLinkThumbData(null)
                .shareLinkSummary("")
                .shareLinkTitle("")
                .shareLinkUrl("")
                .shareLink(mCallback);
    }

    public void wxShareVideo() {
        Auth.withWX(this)
                .shareVideoThumbData(null)
                .shareVideoSummary("")
                .shareVideoLowBandUrl("")
                .shareVideoTitle("")
                .shareVideoUrl("")
                .shareVideo(mCallback);
    }

    public void wxShareMusic() {
        Auth.withWX(this)
                .shareMusicThumbData(null)
                .shareMusicSummary("")
                .shareMusicDataUrl("")
                .shareMusicLowBandDataUrl("")
                .shareMusicLowBandUrl("")
                .shareMusicTitle("")
                .shareMusicUrl("")
                .shareMusic(mCallback);
    }

    public void wxShareApp() {
        Auth.withWX(this)
                .shareAppId("")
                .shareAppPath("")
                .shareAppSummary("")
                .shareAppThumbData(null)
                .shareAppTitle("")
                .shareAppType(1)
                .shareAppUrl("")
                .shareAppWithShareTicket(true)
                .shareApp(mCallback);
    }

    public void ylPay() {
        Auth.withYL(this)
                .payOrderInfo("")
                .payIsTest(true)
                .pay(mCallback);
    }

    public void zfbPay() {
        Auth.withZFB(this)
                .payOrderInfo("")
                .payIsShowLoading(true)
                .pay(mCallback);
    }


    public void zfbRouse() {
        Auth.withZFB(this)
                .rouseUrl("")
                .rouse(mCallback);
    }

返回码

  1. 华为

  2. QQ

    110201:未登陆
    110405:登录请求被限制
    110404:请求参数缺少appid
    110401:请求的应用不存在
    110407:应用已经下架
    110406:应用没有通过审核
    100044:错误的sign
    110500:获取用户授权信息失败
    110501:获取应用的授权信息失败
    110502:设置用户授权失败
    110503:获取token失败
    110504:系统内部错误
    
  3. 微博

    C8998: 签名不一致
    8000: 没有安装客户端
    8001: 非官方客户端
    
  4. 微信

  5. 支付宝

  6. OPPO 为离线文档

说明

  1. 华为:Mac 下集成Agent执行脚本文件没反应。

    GetHMSAgent_cn.sh 换行符的原因导致在macos下执行无反映,可通过下列命令替换下换行符:
    cat GetHMSAgent_cn.sh | tr "^M" "\n" > GetHMSAgent_cn_new.sh

  2. 华为:同时引入其他第三方华为支持时(如极光的华为推送插件)

    禁用华为依赖传递,由于极光插件全量引入了华为SDK,所以全部禁用所有依赖
    implementation ('com.enowr.android:AuthHW:0.0.3'){transitive false}
    引入极光的华为插件,配置相关配置即可
    implementation 'cn.jiguang.sdk.plugin:huawei:3.3.2'

 

你可能感兴趣的:(Android 集成微信、QQ、微博、支付宝、银联、华为、OPPO)