gpt4 book ai didi

android - Facebook 登录 CallbackManager FacebookCallback 每次都调用 onCancel()

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:28:17 26 4
gpt4 key购买 nike

我正在通过 facebook 实现登录并使用 SDK 4.1.0 获取用户电子邮件 ID,如 facebook documentation 所示。但出现的问题是,每次在 onActivityResult 之后调用 registerCallback 而不是调用 onSuccess onCancel 时。

package com.dexterous.hellologin;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;

import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;


public class MainActivity2 extends ActionBarActivity {

CallbackManager callbackManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();

setContentView(R.layout.activity_main_activity2);

LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions("email");
// If using in a fragment
// loginButton.setFragment(this);
// Other app specific specialization
// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
Log.e("TAG", "success");
}

@Override
public void onCancel() {
// App code
Log.e("TAG", "onCancel");
}

@Override
public void onError(FacebookException exception) {
// App code
Log.e("TAG", "error");
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
Log.e("TAG", "onActivityResult");
}
}

每次我得到输出

onActivityResult

取消

我也没有看到包含取消和登录按钮的 Facebook 登录屏幕。

从移动设备上卸载 facebook 应用程序后,错误更改为无效的应用程序 ID

这是堆栈跟踪

06-04 10:55:16.631 19864-19864/com.dexterous.hellologin I/WebViewFactory﹕ Loading com.google.android.webview version 42.0.2311.138 (code 2311138) 06-04 10:55:16.706 19864-19864/com.dexterous.hellologin I/LibraryLoader﹕ Time to load native libraries: 4 ms (timestamps 8772-8776) 06-04 10:55:16.706 19864-19864/com.dexterous.hellologin I/LibraryLoader﹕ Expected native library version number "",actual native library version number "" 06-04 10:55:16.717 19864-19864/com.dexterous.hellologin W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring 06-04 10:55:16.816 19864-19864/com.dexterous.hellologin V/WebViewChromiumFactoryProvider﹕ Binding Chromium to main looper Looper (main, tid 1) {28a6fbd9} 06-04 10:55:16.816 19864-19864/com.dexterous.hellologin I/LibraryLoader﹕ Expected native library version number "",actual native library version number "" 06-04 10:55:16.819 19864-19864/com.dexterous.hellologin I/chromium﹕ [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0 06-04 10:55:16.834 19864-19864/com.dexterous.hellologin I/BrowserStartupController﹕ Initializing chromium process, singleProcess=true 06-04 10:55:16.838 19864-19864/com.dexterous.hellologin W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring 06-04 10:55:16.841 19864-19864/com.dexterous.hellologin E/SysUtils﹕ ApplicationContext is null in ApplicationStatus 06-04 10:55:16.869 19864-19864/com.dexterous.hellologin W/chromium﹕ [WARNING:resource_bundle.cc(286)] locale_file_path.empty() 06-04 10:55:16.870 19864-19864/com.dexterous.hellologin I/chromium﹕ [INFO:aw_browser_main_parts.cc(63)] Load from apk succesful, fd=63 off=46992 len=3337 06-04 10:55:16.871 19864-19864/com.dexterous.hellologin I/chromium﹕ [INFO:aw_browser_main_parts.cc(76)] Loading webviewchromium.pak from, fd:64 off:7953032 len:1161174 06-04 10:55:17.024 19864-19953/com.dexterous.hellologin W/chromium﹕ [WARNING:data_reduction_proxy_config.cc(150)] SPDY proxy OFF at startup 06-04 10:55:17.047 19864-19864/com.dexterous.hellologin W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring 06-04 10:55:17.060 19864-19864/com.dexterous.hellologin W/AwContents﹕ onDetachedFromWindow called when already detached. Ignoring 06-04 10:55:24.893 19864-19864/com.dexterous.hellologin W/BindingManager﹕ Cannot call determinedVisibility() - never saw a connection for the pid: 19864 06-04 10:55:26.140 19864-20020/com.dexterous.hellologin E/Adreno-ES20﹕ : Invalid texture format! Returning error! 06-04 10:55:26.140 19864-20020/com.dexterous.hellologin E/Adreno-ES20﹕ : Framebuffer color attachment incomplete. Returning GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT! 06-04 10:55:26.198 19864-19912/com.dexterous.hellologin E/Adreno-ES20﹕ : Invalid texture format! Returning error! 06-04 10:55:26.198 19864-19912/com.dexterous.hellologin E/Adreno-ES20﹕ : Framebuffer color attachment incomplete. Returning GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT! 06-04 10:58:32.287 19864-19864/com.dexterous.hellologin E/TAG﹕ onCancel 06-04 10:58:32.287 19864-19864/com.dexterous.hellologin E/TAG﹕ onActivityResult 06-04 10:59:25.498 19864-19864/com.dexterous.hellologin I/art﹕ Explicit concurrent mark sweep GC freed 16056(1325KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 9MB/16MB, paused 856us total 79.028ms

list

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

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.dexterous.hellologin.MainActivity2"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main_activity2" >
</activity>

<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="1437829111203883" />

</application>

</manifest>

最佳答案

我注意到 onCancel() 仍然被调用,因为用户已经登录。试着打电话LoginManager.getInstance().logOut()在启动您的登录序列之前

关于android - Facebook 登录 CallbackManager FacebookCallback 每次都调用 onCancel(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30634565/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com