如何通过Facebook
Android SDK 4.0获取Facebook用户ID?
这是我的代码不起作用:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_firstlogin); CallbackManager cm; LoginButton lb; cm = CallbackManager.Factory.create(); lb = (LoginButton) findViewById(R.id.facebook_button); Log.d(TAG,"Salut les zouzous"); LoginManager.getInstance().registerCallback(cm,new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d(TAG,"Success !"); AccessToken tok; tok = AccessToken.getCurrentAccessToken(); Log.d(TAG,tok.getUserId()); } @Override public void onCancel() { Log.d(TAG,"On Cancel"); } @Override public void onError(FacebookException exception) { Log.e(TAG,exception.getMessage()); } });
我确切地知道了
Log.d(TAG," Success");
不打印.
在回调之外只有第一个记录打印内容的日志.
对不起英语不好.