我正試圖去Facebook上的應用程序登錄屏幕。當活動開始時,屏幕顯示一個Facebook加載頁面然後消失,並且頁面被設置爲R.layout.main。應用程序登錄頁面未顯示 - Android Facebook
我在這裏必須缺少重點,但是如何到達用戶登錄頁面以便登錄。
我一直在下面設在https://developers.facebook.com/docs/mobile/android/build/#enablesso
僅供參考教程 - 我已刪除了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登錄失敗的錯誤 – Venky 2012-04-24 14:46:39
我收到消息:04-24 15:54:05.050:D/CLIPBOARD(21628):在開始輸入時隱藏剪貼板對話框:由別人完成......! – user983965 2012-04-24 14:55:15
Post full Logcat – Venky 2012-04-24 14:55:45