Android UmengShareSDK 第三方登录- 今天就不废话了,集成平台第三方登录。市面上集成平台有shareSDK 和 Ument两种,shareSDK的ipa和服务好些,如果自己研究会很方便。其他功能错不多,这骗文章将概述Ument的第三方登录。

  1. 首先你得到友盟上去创建帐户和应用这是链接http://www.umeng.com/,获取你应用的Appkey在manifest中配置。
  2. 下载Ument集成SDK,复制res和blis到你工程中或者添加依赖库并配置mainfest。
  3. 在你的主程中定义UMSocialService。建议在application中
    public static final UMSocialService mController = UMServiceFactory .getUMSocialService("com.umeng.share", RequestType.SOCIAL);
  4. 在初始化init中添加监听
  5. mController.getPlatformInfo(this, SHARE_MEDIA.SINA, new UMDataListener() { @Override public void onStart() { }

    @Override public void onComplete(int status, Map<String, Object> info) { // 相关平台的授权信息都以K-V的形式封装在info中 if (status == 200 && info != null) { StringBuilder sb = new StringBuilder(); Set<String> keys = info.keySet(); token = (String) info.get("access_token"); for (String kStr : keys) { sb.append(kStr + "=" + info.get(kStr).toString() + "\r\n"); } Toast.makeText(MainActivity.this, token, 0).show(); GeneralUtil.DebuggingLog(TAG, sb.toString()); } else GeneralUtil.DebuggingLog(TAG, "失败"); } });

    }`

  6. 第三方登录的信息会在回调后的info中以键值对的形式存在。通过setkey可以拿到键集合。

  7. 接下来就可以保存最重要的token了,完事在你的授权监听中添加 mController.doOauthVerify(this, SHAREMEDIA.SINA, new UMAuthListener() { @Override public void onStart(SHAREMEDIA arg0) { }

    @Override public void onError(SocializeException arg0, SHARE_MEDIA arg1) { } @Override public void onComplete(Bundle arg0, SHARE_MEDIA arg1) { Toast.makeText(MainActivity.this, token, 0).show(); } @Override public void onCancel(SHARE_MEDIA arg0) { } });`
  8. onComplete方法就是成功回调,其他可以参考api.

  • Ument第三方登录讲解到此为止,ument的api并没有很详细,在搜索引擎并未能发现比较直接好的例子。如果参照dome可能会走些弯路。希望这个简单直接的教程能够给后辈们一些个启发。

this is not nonsense, integration platform of third party logging. The market integration platform with shareSDK and Ument two, shareSDK IPA and service better, if your research will be very convenient. The other function is not wrong, this article will provide an overview of Ument third logon.

  1. first you get the alliance to create the account and the application of this is the link [http://www.umeng.com/] (http://www.umeng.com/), get your application in the manifest configuration Appkey.
  2. download Ument integrated SDK, copy the res and BLIS to your project or add library dependencies and configuration of mainfest.
  3. in the LORD your process definition UMSocialService. Suggestions in applicationpublic static final UMSocialService mController = UMServiceFactory .getUMSocialService (&quot; com.umeng.share&quot, RequestType.SOCIAL;);
  4. in the initialization init add monitor
  5. mController.getPlatformInfo (this, SHAREMEDIA.SINA, New UMDataListener () { @Override Public (void onStart) { } @Override Public void onComplete (int status, Map<String, Object> info) { / / relevant platform authorization information in the form of K-V package in info If (status = = 200 & & Info! = null) { StringBuilder sb = new (StringBuilder); Setkeys = info.keySet (); Token = (String) info.get ("accesstoken"); For (String kStr: Keys) { Sb.append (kStr + "=" Info.get (kStr) + (.ToString) + "\r\n"); } Toast.makeText (MainActivity.this, token,.Show (0)); GeneralUtil.DebuggingLog (TAG, sb.toString) (); } else GeneralUtil.DebuggingLog (TAG, "failure"); } }); }`
  6. third party login information will exist in the form of key / value in the callback after info. Through the setkey can get the key set.
  7. then you can save the most important token, and add mController.doOauthVerify in authorization monitoring your in ( this, SHAREMEDIA.SINA, New UMAuthListener () { @Override Public void onStart (SHAREMEDIA arg0) { } @Override Public void onError (SocializeException arg0, SHARE_MEDIA arg1) { } @Override Public void onComplete (Bundle arg0, SHAREMEDIA arg1) { Toast.makeText (MainActivity.this, token,.Show (0)); } @Override Public void onCancel (SHAREMEDIA arg0) { } ');}
  8. onComplete is a success callback, the other can refer to api.

更多相关文章

  1. android平台的几个编译命令----make,mmm,mm,mma
  2. 强制保持Android(安卓)Activity状态
  3. Android(安卓)项目实战视频资料 学习充电必备
  4. [转]如何在移动设备程序中嵌入盈利广告,开始挣钱了 android iphon
  5. android and arm
  6. Android面试之---谈谈你对Android(安卓)NDK的理解.
  7. Cordova插件编写流程(Android平台)
  8. 分析ARM ANDROID市场及技术结合点 转载
  9. 为NetBeans添加Andriod平台

随机推荐

  1. Android(安卓)频道管理仿今日头条
  2. android 平台上SQLite3中文乱码 --我的小
  3. ECLIPSE android 布局页面文件出错故障排
  4. android实现瀑布流加载图片
  5. Android内置颜色及其它颜色RGB对照表
  6. cocos2dx的学习
  7. Android程序开发初级教程(三)
  8. android adb 获取所有app 的uid
  9. Android(安卓)root的两种方法-udev漏洞和
  10. 解决Android(安卓)Logcat不打印信息