Giter VIP home page Giter VIP logo

thirdutils's Introduction

ThirdToolsLib

集成第三方登陆分享(微信/QQ),第三方支付(支付宝,微信,盛付通) 本Demo并不能直接使用,若要使用此项目,请将主项目的applicationId改为你的包名,signingConfigs配置签名配置 #使用方式 gradle引入:

compile 'com.allure0:ThirdToolsLib:1.0.0'

  • 主项目的gradle.properties里必须配置isCompile,默认true,参见demo

    属性 解释
    true 使用libs里的第三包
    false 自行选择功能与第三方jar包

例:只需要使用支付宝的支付功能: 主项目build放入最新的支付宝jar包:

dependencies {
  ···
compile files('libs/alipaySdk-20161222.jar')   
  ···
}

gradle.properties配置:

 isCompile=false

对于QQ需要在主项目build文件配置如下qq_id,将1105787445替换为你的QQ的APPKEY,参见主项目build.gradle

 manifestPlaceholders = [
                qq_id: "1105787445"
        ]

###效果图 image

###初始化配置

PlatformConfig platformConfig = PlatformConfig.getInstance()
                .setQqId("xxx")
                .setWeChatId("xxxx")
                .setWeChatSecret("");//如果是服务处理token和code不需要传此参数

        PlatformManager.getInstance()
                .setPlatformConfig(platformConfig)
                .initQQ(this)
                .initWx(this);

###QQ登陆

     LoginManager
                .with(MainActivity.this)
                .thirdLogin(LoginPlatform.PLATFORM_QQ);              

###微信登陆

 LoginManager.with(MainActivity.this)
             .thirdLogin(LoginPlatform.PLATFORM_WECHAT);

###微信分享

 ShareUtils.initShareUtils(
                        BaseApplication.getInstance(), text, text, imgUrl, url,
                        BitmapFactory.decodeResource(BaseApplication.getInstance().getResources(),
                                R.drawable.ic_launcher)
                ).shareToWX(MainActivity.this, ShareUtils.WECHAT_CIRCLE);

QQ分享

ShareUtils.initShareUtils(
                        BaseApplication.getInstance(), text, text, imgUrl, url,
                        BitmapFactory.decodeResource(BaseApplication.getInstance().getResources(),
                                R.drawable.ic_launcher)
                ).shareToQQ(MainActivity.this, "测试啦");

###微信支付

  PayManager.with(MainActivity.this)
            .wxPay( wxPayBean);

###支付宝支付

 PayManager.with(MainActivity.this)
           .aliPay(ali_orderinfo, new AliPayListener() {
                            @Override
                            public void aliPayResult(String string, AliPayResult payResult) {
                                Log.e("支付状态", string);
                                Log.e("支付状态", payResult.getResultStatus());
                            }
                        });

###观察者模式接受处理结果

 @Override
    public void thirdLoginSuccess(Object obj, LoginPlatform platform, LoginResult loginResult) {

    }

    @Override
    public void thirdLoginFailed(Object object, LoginPlatform loginPlatform) {

    }

    @Override
    public void thirdLoginCancel(LoginPlatform loginPlatform) {

    }

    @Override
    public void shareSuccess(SharePlatform sharePlatform) {

    }

    @Override
    public void shareFailed(SharePlatform sharePlatform) {

    }

    @Override
    public void paySuccess(PayPlatform payPlatform) {

    }

    @Override
    public void payFailed(PayPlatform payPlatform) {

    }

若有BUG或者疑问,请提交Issues。者QQ群:482906631

#License Copyright 2017 Allure

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.