三方登录

当点击第三方登录时,先在MOB下载完,导入包后,在点击的地方写
微博的:

   Platform weibo = ShareSDK.getPlatform(SinaWeibo.NAME);
            //回调信息,可以在这里获取基本的授权返回的信息,但是注意如果做提示和UI操作要传到主线程handler里去执行
            weibo.setPlatformActionListener(new PlatformActionListener() {
                @Override
                public void onError(Platform arg0, int arg1, Throwable arg2) {
                    // TODO Auto-generated method stub
                    arg2.printStackTrace();
                }

                @Override
                public void onComplete(Platform arg0, int arg1, HashMap arg2) {
                    // TODO Auto-generated method stub
                    //输出所有授权信息
                    arg0.getDb().exportData();
                }

                @Override
                public void onCancel(Platform arg0, int arg1) {
                    // TODO Auto-generated method stub

                }
            });
            //authorize与showUser单独调用一个即可
            weibo.authorize();//单独授权,OnComplete返回的hashmap是空的
            weibo.showUser(null);//授权并获取用户信息
            //移除授权
            //weibo.removeAccount(true);

QQ的:

  Platform qqPlatform = ShareSDK.getPlatform(QQ.NAME);
            qqPlatform.setPlatformActionListener(new PlatformActionListener() {
                @Override
                public void onComplete(Platform platform, int i, HashMap hashMap) {

                }

                @Override
                public void onError(Platform platform, int i, Throwable throwable) {

                }

                @Override
                public void onCancel(Platform platform, int i) {

                }
            });
            qqPlatform.authorize();

你可能感兴趣的:(三方登录)