应用程序登录页面未显示 - Facebook的Android版 [英] App login page not shown - Android Facebook
问题描述
我试图去Facebook上的应用程序登录屏幕。当活动开始后,屏幕上显示一个Facebook页面加载,然后消失,页面设置为R.layout.main。
I am trying to get to the app login screen on Facebook. When the activity is started, the screen shows a facebook loading page then disappears and the page is set to the R.layout.main.
我必须在这里失去了点,但我怎么去应用程序登录页面的用户登录,请
I must be missing the point here, but how do I get to the app login page for the user to login please.
我一直在下面设在 HTTPS教程://developers.facebook .COM /文档/手机/安卓/编译/#enablesso
仅供参考 - 我已经删除了APP_ID
FYI - I have removed the APP_ID
package com.example.facebook;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import com.facebook.android.DialogError;
import com.facebook.android.Facebook;
import com.facebook.android.Facebook.DialogListener;
import com.facebook.android.FacebookError;
public class MyGreatActivity extends Activity {
Facebook facebook = new Facebook("APP_ID");
private SharedPreferences mPrefs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*
* Get existing access_token if any
*/
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}
/*
* Only call authorize if the access_token has expired.
*/
if(!facebook.isSessionValid()) {
facebook.authorize(this, new String[] {}, new DialogListener() {
@Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
}
感谢您的帮助。
推荐答案
看来你的手机中包含的Facebook原生应用的话,它可能会抛出的登录失败无效键错误在logcat中。
Seems your Mobile contains Facebook Native App so , it might throws login failed invalid key error in Logcat.
如果碰巧是问题,因为单点登录。所以你需要创建Android的密钥散列,并在您的应用程序注册。
If it happens that is problem due to Single Sign On .. So you need to create Android Key Hash and register in your app..
按照此步骤这样做。
您可以禁用单点登录的单线,无需使用创建哈希键,但这是不推荐的方法来处理
You can disable Single Sign On in Single line and no need to use Create Hash Key but this is not recommended way to handle.
添加 1 或 Facebook.FORCE_DIALOG_AUTH 到授权()
facebookObject.authorize(context, PERMISSIONS,Facebook.FORCE_DIALOG_AUTH,new LoginListener());
这篇关于应用程序登录页面未显示 - Facebook的Android版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!