• QQ登入(1)-有客户端直接授权,没客户端web授权


    准备jar文件3个:

    android-support-v4.jar

    下载地址:http://pan.baidu.com/s/1eQmoTm6

    mta-sdk-1.6.2.jar

    下载地址:http://pan.baidu.com/s/1vk4Bc

    open_sdk.jar

    下载地址:http://pan.baidu.com/s/1o64V0Em

    添加权限

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    添加腾讯授权和支持页面activity

    <activity
    android:name="com.tencent.connect.common.AssistActivity"
    android:configChanges="orientation|keyboardHidden"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />

    <activity
    android:name="com.tencent.tauth.AuthActivity"
    android:launchMode="singleTask"
    android:noHistory="true" >
    <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="tencent222222" />
    <!-- 100380359 100381104 222222 -->
    </intent-filter>
    </activity>

    添加页面代码:

    package sdkjfs.e;
    
    import org.json.JSONObject;
    
    import com.tencent.connect.auth.QQAuth;
    import com.tencent.tauth.IUiListener;
    import com.tencent.tauth.Tencent;
    import com.tencent.tauth.UiError;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Toast;
    
    public class MyQQloginShareActivity extends Activity {
        public  String mAppid="222222";
        public  QQAuth mQQAuth;
        private Tencent mTencent;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            mQQAuth = QQAuth.createInstance(mAppid, getApplicationContext());
            mTencent = Tencent.createInstance(mAppid, getApplicationContext());
        }
        public void myclick(View v){
            IUiListener listener = new IUiListener() {
                @Override
                public void onCancel() {
                Toast.makeText(getApplicationContext(), "取消登入", 0).show();            
                }
                @Override
                public void onComplete(Object arg0) {
                    Toast.makeText(getApplicationContext(), "登录成功", 0).show();  
    getUserInfo(); //获取用户信息 } @Override
    public void onError(UiError arg0) { Toast.makeText(getApplicationContext(), "登录失败", 0).show(); } }; mTencent.login(this, "all", listener); } }

     退出登入:mTencent.logout(getApplicationContext());

    完整案例源码: 源码:链接: http://pan.baidu.com/s/1qWwJQ24 

  • 相关阅读:
    Eclipse Java开发环境配置 + memcached + maven
    sqlserver数据库自动备份
    从表A中选择部分字段插入到表B
    电信IOT平台关于产品profile插件的添加流程
    SQLServer查询耗时sql语句
    net core 包管理
    byte[] 截串操作
    关于kafka启动失败问题
    springboot 搭建maven项目
    C# MongoDB学习之路(一)
  • 原文地址:https://www.cnblogs.com/clarence/p/3675751.html
Copyright © 2020-2023  润新知