Android-Facebook登录仅第一次导致onResume错误
我可以成功连接到facebook并获得好友列表。所有连接都正常。 但当我删除Facebook(通过设置->应用程序)和我的应用程序的数据时,就会出现登录问题。[SDK 3.5]Android-Facebook登录仅第一次导致onResume错误,android,login,facebook-android-sdk,onresume,Android,Login,Facebook Android Sdk,Onresume,我可以成功连接到facebook并获得好友列表。所有连接都正常。 但当我删除Facebook(通过设置->应用程序)和我的应用程序的数据时,就会出现登录问题。[SDK 3.5] 启动我的应用程序 建立facebook连接 Facebook要求输入用户名和密码,然后输入 稍等 它显示权限屏幕,询问基本用户信息,出现错误:“您的应用程序意外停止工作。请重试(强制关闭)” 当我单击“强制关闭”时,相同的错误会一次又一次地突然出现(权限屏幕仍在后面)。如果我可以足够快,我点击强制关闭,然后允许权限,一切
第一次连接后,我可以毫无错误地找到我的朋友。这只发生在我第一次连接Facebook之后,它会询问我的用户名和密码(然后单击登录) 这个startOrContinueAuth方法是在com.Facebook.LoginActivity中启动的
@Override
public void onResume() {
super.onResume();
// If the calling package is null, this generally means that the callee was started
// with a launchMode of singleInstance. Unfortunately, Android does not allow a result
// to be set when the callee is a singleInstance, so we log an error and return.
if (callingPackage == null) {
Log.e(TAG, "Aheyy"+NULL_CALLING_PKG_ERROR_MSG);
finish();
return;
}
authorizationClient.startOrContinueAuth(request);
}
if (getInProgress()) {
continueAuth();
} else {
authorize(request);
}
}
更新2
- 我很困惑。我把我的申请简化为最基本的 openActiveSession()方法。撞车
- 我尝试了Facebook、FriendPicker和it的示例应用程序 与相同的日志错误输出一起崩溃
- 在emulator上试用过,它可以工作,但当我旋转屏幕时 显示授权屏幕(取消允许),出现相同错误(无法 继续胡说八道……) 在Facebook的示例应用程序上出现同样的错误是很奇怪的
在facebook版本3.5.1中修复了很多关于身份验证和应用程序事件日志的问题,所以可能在最新版本中已经解决了,可以从下载。
我希望它能解决您的问题:)基本上,当呼叫活动未激活或被破坏时,就会出现此问题。在android中,在登录后调用activityResult()方法。手机会强制销毁活动(在“开发人员选项”设置中启用“不保留活动”选项)。请在“开发人员选项”设置中交叉检查“不保留”活动是否已启用或禁用。请确保清单中的lgin活动处于纵向状态。如果活动不是纵向的,则会出现丢失活动的问题。这非常糟糕…:|能否发布活动/片段代码?添加了部分代码,requestMyAppFacebookFriends(会话会话)在状态更改后执行。是否从调用()内部调用requestMyAppFacebookFriends(会话会话)在检查station.isopend()之后的回调中?是的,我在.isopend()之后调用它。经过多次测试,我发现应用程序有时不会崩溃。它只是有时工作,通常不工作。我认为这与我的方法(picfriend等)无关。我只留下了openSession代码,并注释了其他内容,如pickfriend、requestMe等,错误仍然发生。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(this, callback);
uiHelper.onCreate(savedInstanceState);
setContentView(R.layout.activity_fb_findfriends);
LinearLayout v = (LinearLayout) findViewById(R.id.fb_app_users);
openSession(v);
}
public void openSession(View v){
// start Facebook Login
Session.openActiveSession(this, true, callback);
}
@Override
protected void onResume() {
super.onResume();
uiHelper.onResume();
Log.e("ONRESUME", "Onresume çalıştı");
}
private void requestMyAppFacebookFriends(Session session) {
Request friendsRequest = createRequest(session);
friendsRequest.setCallback(new Request.Callback() {
@Override
public void onCompleted(Response response) {
List<GraphUser> friends = getResults(response);
//Display Friends
}
});
friendsRequest.executeAsync();
}
void startOrContinueAuth(AuthorizationRequest request) {
if (appEventsLogger == null || appEventsLogger.getApplicationId() != request.getApplicationId()) {
Log.e("HATA!", "BOOM");
appEventsLogger = AppEventsLogger.newLogger(context, request.getApplicationId());
}
@Override
public void onResume() {
super.onResume();
// If the calling package is null, this generally means that the callee was started
// with a launchMode of singleInstance. Unfortunately, Android does not allow a result
// to be set when the callee is a singleInstance, so we log an error and return.
if (callingPackage == null) {
Log.e(TAG, "Aheyy"+NULL_CALLING_PKG_ERROR_MSG);
finish();
return;
}
authorizationClient.startOrContinueAuth(request);
}
if (getInProgress()) {
continueAuth();
} else {
authorize(request);
}
}