使用舊版 SDK (2.9.3) 實現 QQ 登入,登入成功但無法收到回調獲取 userinfo,Logcat 顯示:
E/openSDK_LOG.UIListenerManager: setListener action is null! rquestCode=11101
Activity 與 IntentFilter 宣告。dependencies {
implementation 'com.tencent.connect:qq-sdk:3.3.0' // 以最新版為準
}
<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="tencent{APP_ID}" /> <!-- 替換為你的 App ID -->
</intent-filter>
</activity>
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="orientation|keyboardHidden|screenSize" />
mTencent = Tencent.createInstance(APP_ID, getApplicationContext());
if (!mTencent.isSessionValid()) {
mTencent.login(this, "all", new BaseUiListener());
}
tencent{APP_ID} 完全一致(大小寫敏感)。onComplete 回調,拿到 access_token、openid。騰訊開放平台文檔:Android SDK 接入指南