android–Facebook活动未在facebook-sdk 4.4.0中正确加载

概述我想在我的Android应用程序中集成Facebook登录.我使用的是Facebook-sdk-4.4.0.使用LoginManager类方法.但是我在运行以下代码时面临问题–FacebookSdk.sdkInitialize(getApplicationContext());callbackmanager=CallbackManager.Factory.create();//Setpermissions

我想在我的Android应用程序中集成Facebook登录.我使用的是Facebook-sdk-4.4.0.使用LoginManager类方法.但是我在运行以下代码时面临问题 –

FacebookSdk.sdkInitialize(getApplicationContext());    callbackmanager = CallbackManager.Factory.create();// Set permissionsLoginManager.getInstance().logInWithReadPermissions((Activity)getContext(), Arrays.asList("email", "public_profile"));LoginManager.getInstance().registerCallback(callbackmanager,        new FacebookCallback<LoginResult>() {            @OverrIDe            public voID onSuccess(LoginResult loginResult) {                GraphRequest request = GraphRequest.newMeRequest(                        loginResult.getAccesstoken(),                        new GraphRequest.GraphJsONObjectCallback() {                            @OverrIDe                            public voID onCompleted(JsONObject userInfo, GraphResponse graphResponse) {                                try {                                    FacebookClIEntController.setUserID(userInfo.optString(ID));                                    FacebookClIEntController.setdisplayname(userInfo.optString(name));                                    FacebookClIEntController.setEmailAddress(userInfo.optString(EMAIL));                                    JsONObject picJson = userInfo.getJsONObject(PICTURE).getJsONObject("data");                                    FacebookClIEntController.setProfilePicUrl(picJson.optString("url"));                                    Log.d(LOGTAG, "\nUsername :" + FacebookClIEntController.getdisplayname());                                    Log.d(LOGTAG, "\nEmail :" + FacebookClIEntController.getEmailAddress());                                    Log.d(LOGTAG, "\nUserID :" + FacebookClIEntController.getUserID());                                    Log.d(LOGTAG, "\nProfilePicUrl :" + FacebookClIEntController.getProfilePicUrl());                                } catch (JsONException e) {                                    Log.d(LOGTAG, "Json Error");                                }                            }                        }                );                Bundle parameters = new Bundle();                parameters.putString(FIELDS, FB_REQUEST_FIELDS);                request.setParameters(parameters);                GraphRequest.executeBatchAsync(request);                Toast.makeText(getContext(), "Login successful" + loginResult.toString(), Toast.LENGTH_SHORT).show();            }            @OverrIDe            public voID onCancel() {                Log.d(LOGTAG, "On cancel");            }            @OverrIDe            public voID one rror(FacebookException error) {                Log.d(LOGTAG, error.toString());            }        });}

我正在我的应用程序中的左侧屏幕而不是正确的屏幕,这应该运行上面的代码.谁能告诉我哪里可以出问题?
logcat的:

——— beginning of /dev/log/main

I/AppHost.AndroID(10873): Registered Listener for handling
onActivityResult: com.example.office.docsui.common.SignInController$5

——— beginning of /dev/log/system

I/ActivityManager( 449): START u0 {act=NATIVE_WITH_FALLBACK
cmp=com.example.office.powerworld/com.facebook.FacebookActivity (has
extras)} from pID 10873

I/TelemetrylifeCycleState(10873): Activity Pause Start.
Activity:1099625720,PPTActivity, AppState=3

I/ActivityManager( 449): START u0 {act=NATIVE_WITH_FALLBACK
cmp=com.example.office.powerworld/com.facebook.FacebookActivity (has
extras)} from pID 10873

I/TelemetrylifeCycleState(10873): Activity Pause End.
Activity:1099625720,PPTActivity, AppState=2

I/TelemetrylifeCycleState(10873): Activity Created.
Activity:1107534680,com.facebook.FacebookActivity

I/AppHost.AndroID(10873): onActivityStarted,
foregroundActivityCount=1, mEventsEnabled= true, mResumeEnabled=false

I/AppHost.AndroID(10873): this is not an office
activity::com.facebook.FacebookActivity

I/TelemetrylifeCycleState(10873): Activity Resume Start.
Activity:1107534680,com.facebook.FacebookActivity, AppState=2

I/TelemetrylifeCycleState(10873): Activity Resume End.
Activity:1107534680,com.facebook.FacebookActivity, AppState=3,
suspensionTime=54215

I/TelemetrylifeCycleState(10873): Activity Pause Start.
Activity:1107534680,com.facebook.FacebookActivity, AppState=3

I/TelemetrylifeCycleState(10873): Activity Pause End.
Activity:1107534680,com.facebook.FacebookActivity, AppState=2

I/TelemetrylifeCycleState(10873): Activity Created.
Activity:1107673504,com.facebook.FacebookActivity

D/dalvikvm(10873): GC_FOR_ALLOC freed 2064K, 20% free 8974K/11096K,
paused 27ms, total 30ms

I/AppHost.AndroID(10873): onActivityStarted,
foregroundActivityCount=1, mEventsEnabled= true, mResumeEnabled=false

I/AppHost.AndroID(10873): this is not an office
activity::com.facebook.FacebookActivity

I/TelemetrylifeCycleState(10873): Activity Resume Start.
Activity:1107673504,com.facebook.FacebookActivity, AppState=2

I/TelemetrylifeCycleState(10873): Activity Resume End.
Activity:1107673504,com.facebook.FacebookActivity, AppState=3,
suspensionTime=54303

D/mali_winsys(10873): new_window_surface returns 0x3000

D/mali_winsys(10873): new_window_surface returns 0x3000

D/mali_winsys(10873): new_window_surface returns 0x3000

D/mali_winsys(10873): new_window_surface returns 0x3000

I/Keyboard.Facilitator( 614): onFinishinput()

I/ActivityManager( 449): displayed
com.example.office.powerworld/com.facebook.FacebookActivity: +346ms

I/ActivityManager( 449): displayed
com.example.office.powerworld/com.facebook.FacebookActivity: +346ms

D/mali_winsys(10873): new_window_surface returns 0x3000

D/mali_winsys(10873): new_window_surface returns 0x3000

I/K2_ulS (10873): 07/21/2015 17:24:38.293 PPTDROID
(0x2a79) 0x40066154 Example powerworld AppHost
PLM a2k0b Medium PauseHandlerActivitylifecycleCallbacks:onActivitySaveInstanceState
called

I/Keyboard.Facilitator( 614): onFinishinput()

W/inputMethodManagerService( 449): Window already focused, ignoring
focus gain of:
com.androID.internal.vIEw.IinputMethodClIEnt$Stub$Proxy@4227f090
attribute=androID.vIEw.inputmethod.EditorInfo@423ba3a8, token =
androID.os.BinderProxy@41f633d8

解决方法:

试试这个吧

Loginbutton loginbutton;CallbackManager callbackManager;FacebookSdk.sdkInitialize(getApplicationContext());callbackManager = CallbackManager.Factory.create();loginbutton = (Loginbutton) findVIEwByID(R.ID.login_button);    loginbutton.setReadPermissions(Arrays.asList("public_profile", "user_frIEnds", "email"));    loginbutton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {        @OverrIDe        public voID onSuccess(LoginResult loginResult) {            Profile profile = Profile.getCurrentProfile();            profile.getProfilePictureUri(315, 315);            GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccesstoken(),                    new GraphRequest.GraphJsONObjectCallback() {                        @OverrIDe                        public voID onCompleted(JsONObject object, GraphResponse response) {                            Log.v("LoginActivity", response.toString());                        }                    });            Bundle parameters = new Bundle();            parameters.putString("fIElds", "ID,name,email");            request.setParameters(parameters);            request.executeAsync();        }        @OverrIDe        public voID onCancel() {        }        @OverrIDe        public voID one rror(FacebookException e) {            e.printstacktrace();        }    });

并覆盖以下方法

@OverrIDeprotected voID onActivityResult(int requestCode, int resultCode, Intent data) {    super.onActivityResult(requestCode, resultCode, data);    callbackManager.onActivityResult(requestCode, resultCode, data);         }

并在清单中定义它

<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"/>
总结

以上是内存溢出为你收集整理的android – Facebook活动未在facebook-sdk 4.4.0中正确加载全部内容,希望文章能够帮你解决android – Facebook活动未在facebook-sdk 4.4.0中正确加载所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1118141.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存